Answers for "list in android studio"

0

android java list view

ListView friendsListView = findViewById(R.id.friendListView);
final ArrayList<String> myFriends = new ArrayList<String>(asList("Mark","Jane","Sussy","Jan"));
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, myFriends);
friendsListView.setAdapter(arrayAdapter); // Set an adapter
friendsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
   @Override
   public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
       Toast.makeText(getApplicationContext(), "Hello " + myFriends.get(i), Toast.LENGTH_LONG).show();
Posted by: Guest on January-05-2021
0

how to use listview in android studio

ArrayAdapter adapter = new ArrayAdapter<String>(this,R.layout.ListView,StringArray);
Posted by: Guest on June-20-2021

Code answers related to "list in android studio"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language