Practical 8 code
Practical 8 code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/SearchEngine"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/SearchEngine"
android:hint="@string/SearchEngine"
android:completionThreshold="1"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit"
android:id="@+id/Submit"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Display"
android:text=""
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="@color/black"/>
</LinearLayout>
package com.example.edit;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button submit=findViewById(R.id.Submit);
TextView display=findViewById(R.id.Display);
submit.setOnClickListener(v->{
String SearchEngine=textView.getText().toString();
display.setText(getString(R.string.Display,SearchEngine));
}
);
}
}
2:-
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="10sp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Sem"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Sub1"
android:hint="@string/Sub1"
android:completionThreshold="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Sem"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Sub2"
android:hint="@string/Sub2"
android:completionThreshold="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Sem"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Sub3"
android:hint="@string/Sub3"
android:completionThreshold="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Sem"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Sub4"
android:hint="@string/Sub4"
android:completionThreshold="1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Sem"/>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Sub5"
android:hint="@string/Sub5"
android:completionThreshold="1"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Submit"
android:id="@+id/Submit"
android:layout_gravity="center"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/Display"
android:text=""
android:layout_gravity="center"
android:textSize="25sp"
android:textColor="@color/black"/>
</LinearLayout>
package com.example.edit;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sub1.setAdapter(adp);
sub1.setThreshold(1);
sub2.setAdapter(adp);
sub2.setThreshold(1);
sub3.setAdapter(adp);
sub3.setThreshold(1);
sub4.setAdapter(adp);
sub4.setThreshold(1);
sub5.setAdapter(adp);
sub5.setThreshold(1);
Button submit=findViewById(R.id.Submit);
TextView display=findViewById(R.id.Display);
submit.setOnClickListener(v->{
String Sub1=sub1.getText().toString();
String Sub2=sub2.getText().toString();
String Sub3=sub3.getText().toString();
String Sub4=sub4.getText().toString();
String Sub5=sub5.getText().toString();
display.setText(getString(R.string.Display,Sub1,Sub2,Sub3,Sub4,Sub5));
}
);
}
}