Android Ass 2

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

//---------------------------------------------------------

Header-------------------------
NAME :AARTI SHARMA
CLASS :T.Y. BSC.CS
DIV :A
PC_NO :SRKI_60
ENROLLMENT ID :E19110192000310103
//---------------------------------------------------------------------------------
-------

//-------------------------design code of feedback form---------------------------


//Mainactivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:textAlignment="center"
tools:context=".MainActivity">

<TextView
android:id="@+id/lbl_feedback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Feedback form"
android:textAlignment="center"
android:textSize="30sp" />

<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:paddingTop="30dp">

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="30dp">

<TextView
android:id="@+id/lbl_en_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Enrollment id" />

<EditText
android:id="@+id/txt_en_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/lbl_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Full Name" />

<EditText
android:id="@+id/txt_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/lbl_sem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="semester" />

<Spinner
android:id="@+id/drop_down_sem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:spinnerMode="dropdown" />

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/lbl_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Please select " />

<RadioGroup
android:id="@+id/rg_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">

<RadioButton
android:id="@+id/rdb_helpful"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Helpful " />

<RadioButton
android:id="@+id/rdb_not"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Not helpful" />
</RadioGroup>
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/lbl_remark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Remark" />

<EditText
android:id="@+id/txt_remark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/lbl_tech"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="On which technology do you wish seminars in
future?" />

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<CheckBox
android:id="@+id/chx_cyber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cyber Security" />

<CheckBox
android:id="@+id/chx_datascience"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Data science" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="show_info">

<Button
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:paddingLeft="20dp"
android:text="SUBMIT"
android:onClick="show_info"/>
</TableRow>
</TableLayout>
</LinearLayout>

//------------------------main code file----------------


//MainActivity.java

package com.example.feedback_application;

import static android.app.ProgressDialog.show;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.content.Intent;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


EditText txt_enroll ,txt_name,txt_remark;
Button btn_sub;
String enroll,s_name,s_review,selected_sem="",radio_string,chx_string="";
Spinner drop_sem;
Integer[] sem = {1,2,3,4,5,6};
CheckBox c1,c2;
RadioButton rb_select;
RadioGroup rg_select;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_sub=findViewById(R.id.btn_submit);
txt_enroll=findViewById(R.id.txt_en_id);
txt_name=findViewById(R.id.txt_name);
txt_remark=findViewById(R.id.txt_remark);
rg_select=findViewById(R.id.rg_1);
c1=findViewById(R.id.chx_cyber);
c2=findViewById(R.id.chx_datascience);
drop_sem=findViewById(R.id.drop_down_sem);
ArrayAdapter<Integer> adp = new
ArrayAdapter<Integer>(getApplicationContext(),
android.R.layout.simple_spinner_dropdown_item,sem);
drop_sem.setAdapter(adp);
drop_sem.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int
i, long l) {
selected_sem=drop_sem.getSelectedItem().toString();

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});

public void show_info(View view) {


enroll=txt_enroll.getText().toString();
s_name=txt_name.getText().toString();
s_review=txt_remark.getText().toString();
int radio_id = rg_select.getCheckedRadioButtonId();
rb_select=findViewById(radio_id);
radio_string=rb_select.getText().toString();
if(c1.isChecked())
{
chx_string=c1.getText().toString();
}
if(c2.isChecked())
{
chx_string=chx_string+c2.getText().toString();
}
// Toast.makeText(this, "details: "+enroll+"\n"+s_name+"\n"+s_review+"\
n"+selected_sem+"\n"+radio_string+"\n"+chx_string, Toast.LENGTH_LONG).show();
Intent i = new Intent(getApplicationContext(),try_activity.class);
i.putExtra("enroll_id",enroll);
i.putExtra("stud_name",s_name);
i.putExtra("sem",selected_sem);
i.putExtra("selected_help",radio_string);
i.putExtra("remarks",s_review);
i.putExtra("technology",chx_string);
startActivity(i);
}
}

//----------------------------second activity-----------------------------
//try_activity.java
package com.example.feedback_application;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;

public class try_activity extends AppCompatActivity {


Button btn_1;
Spinner sp1;
String s;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_try);
Intent obj = getIntent();
String enroll_id=obj.getStringExtra("enroll_id");
String stud_name=obj.getStringExtra("stud_name");
String sem=obj.getStringExtra("sem");
String selected_radio=obj.getStringExtra("selected_help");
String remarks=obj.getStringExtra("remarks");
String chx_string=obj.getStringExtra("technology");
Toast.makeText(this, "your responses : \n"+"enrollment id:"+enroll_id+"\
n"+"Name : "+stud_name+"\n"+"slected sem : "+sem+"\n"+selected_radio+"\
n"+"Remarks : "+remarks+"\n"+"Future seminars : "+chx_string,
Toast.LENGTH_LONG).show();
}
}

You might also like