publicvoidlistView(){ list_view =(ListView)findViewById(R.id.listView); ArrayAdapter<String> adapter =new ArrayAdapter<String>(this,R.layout.name_list,NAMES); list_view.setAdapter(adapter); list_view.setOnItemClickListener( new AdapterView.OnItemClickListener(){ @Override publicvoidonItemClick(AdapterView<?> parent, View view,int position,long id){ String value =(String)list_view.getItemAtPosition(position); Toast.makeText(MainActivity.this,"Position : "+ position +" Value : "+ value, Toast.LENGTH_LONG).show(); } } ); } @Override publicbooleanonCreateOptionsMenu(Menu menu){ // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); returntrue; }
@Override publicbooleanonOptionsItemSelected(MenuItem item){ // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId();
Searches related to android listview example android custom listview example android listview example with images android dynamic listview example android listview example with database android listview example with button android listview example arrayadapter android listview example with custom adapter android listview in fragment example
Extra Tags : Android, programming, tutorial, beginners , develop, ,mobile phone, Environment Setup, Application Components, Activity Lifecycle, Service Lifecycle, Application Architecture, Publishing Application, Debugging Applications, Hadnling Events, Layouts, User Interface Controls, Styles and Themes, Handling Rotation, data storage, managing media, Send Email, Send SMS, Phone Calls
0 comments:
Post a Comment