I am Trying to inflate one ListView When clicking a member of another ListView Which is in a ListActivity. So when I try to set Adapter it asks me for getApplicationContext, so the ListView is in another activity and I am trying to call that that applicationContext from another the ListActivity which will inflate the ListView if you click it.
I am Doing this and I dont Know If I am right or wrong
public class FirstList extends ActionBarActivity{
public static ListView firstL;
public static ArrayList<Friend> friendSelected= new ArrayList<>();
public static Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conversation_list_layout);
context = getApplicationContext();
firstL= (ListView)findViewById(R.id.listView1);
}
}
Second Class
private class FriendSelectorAdapter extends ArrayAdapter<Friend> {
public ChatListAdapter(){
super(FirstList.context,R.layout.list_layout, FirstList.friendSelected);
}
In the second class there is a ListActivity which is displaying all my contacts and this adapter is meant to be called when one of the contacts is clicked so it will populate the listView of the first class.
Am I wrong what i am doing here? I would appreciate any answer, Thanks