Main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<SearchView
android:id="@+id/mainSearchView"
android:queryHint="Search your country"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:id="@+id/mainSearchView"
android:queryHint="Search your country"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/mainListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:id="@+id/mainListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Java
package com.kc.searchdialog;
package com.kc.searchdialog;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.widget.SearchView.*;
import android.os.*;
import android.widget.*;
import android.widget.SearchView.*;
public class MainActivity extends Activity
{
ArrayAdapter <String> ad;
String country[]={
"USA","UK", "Nepal", "UAE",
"China","Bangladesh", "India", "Japan",
"Korea","Russia", "Bhutan", "Afganistan",
"Pakistan","Australia",
};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ad=new ArrayAdapter<String>(
this,
android.R.layout.simple_expandable_list_item_1,country);
ListView lll=(ListView)findViewById(R.id.mainListView);
SearchView sss=(SearchView)findViewById(R.id.mainSearchView);
lll.setAdapter(ad);
sss.setOnQueryTextListener(new OnQueryTextListener(){
{
ArrayAdapter <String> ad;
String country[]={
"USA","UK", "Nepal", "UAE",
"China","Bangladesh", "India", "Japan",
"Korea","Russia", "Bhutan", "Afganistan",
"Pakistan","Australia",
};
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ad=new ArrayAdapter<String>(
this,
android.R.layout.simple_expandable_list_item_1,country);
ListView lll=(ListView)findViewById(R.id.mainListView);
SearchView sss=(SearchView)findViewById(R.id.mainSearchView);
lll.setAdapter(ad);
sss.setOnQueryTextListener(new OnQueryTextListener(){
@Override
public boolean onQueryTextSubmit(String p1)
{
// TODO: Implement this method
return false;
}
public boolean onQueryTextSubmit(String p1)
{
// TODO: Implement this method
return false;
}
@Override
public boolean onQueryTextChange(String ppp)
{
ad.getFilter().filter(ppp);
// TODO: Implement this method
return false;
}
});
}
}
public boolean onQueryTextChange(String ppp)
{
ad.getFilter().filter(ppp);
// TODO: Implement this method
return false;
}
});
}
}
0 comments:
Post a Comment