• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help clickable, searchable listview from item-string?

ElChief

Lurker
Hi everyone!

can somebody help me making my searchable list clickable? I want to start a new activity through the click.

I am a total noob and dont understand much... would be greatful for just a piece of code!

my activity looks like that:


public class Activity extends AppCompatActivity {

ListView list;
ArrayAdapter<String> adapter;

@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_1);



list =(ListView) findViewById(R.id.list);

ArrayList<String> list1 = new ArrayList<>();
list1.addAll(Arrays.asList(getResources().getStringArray(R.array.list_1)));


adapter = new ArrayAdapter<String>(
Activity.this,
android.R.layout.simple_list_item_1,
list1
);



list.setAdapter(adapter);





}


@override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.search_menu, menu);
MenuItem item = menu.findItem(R.id.list_1);
SearchView searchView = (SearchView) item.getActionView();

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@override
public boolean onQueryTextSubmit(String s) {
return false;
}

@override
public boolean onQueryTextChange(String s) {
adapter.getFilter().filter(s);
return false;
}
});

return super.onCreateOptionsMenu(menu);



}
}
 
Back
Top Bottom