I am trying show popup on image click listener and from that popup I want fetch value but I am not getting value from popup. I am calling Itemclicklistener from on click listener but it's not working.
This is my code:
public void onClick(View view)
{
if(view.getId()==R.id.imgv_search)
{
LayoutInflater inflator = (LayoutInflater)Home.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View show_menu_popup = inflator.inflate(R.layout.popup_list, null);
ListView listv_problems = (ListView) show_menu_popup.findViewById(R.id.listv_problems);
AdapterCity city = new AdapterCity(Home.this,al_cityid,al_cityname);
listv_problems.setAdapter(city);
Dialog dialog_menus = new Dialog(Home.this);
dialog_menus.setTitle("Select city : ");
dialog_menus.setContentView(show_menu_popup);
dialog_menus.show();
listv_problems.setOnItemClickListener(this);
//Toast.makeText(Home.this,"City is changed : "+edt_city_name.getText(),Toast.LENGTH_SHORT).show();
}
}
And this is my OnItemclickListener:
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l)
{
if(adapterView.getId()== R.id.listv_problems)
{
//TextView cityid= (TextView)adapterView.findViewById(R.id.cityid);
//String city_id= cityid.getText().toString();
Toast.makeText(Home.this,"You click popup",Toast.LENGTH_LONG);
}
}
You can use...
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
al_citynames.get(position);
//this will give you the value of city
Toast.makeText(Home.this,"You click popup",Toast.LENGTH_LONG);
}
Or you can use view.getitembyposition()
inside onItemClick();