SimpleAdapter adapter = new SimpleAdapter(OnlineMembersActivity.this,
mylist , R.layout.searchresultslistitem,
new String[] { "username",
"DOB","custom","Country_str_name","SEX","Profile_Pic", "mm"},
new int[] { R.id.tv_searchresults_membername,
R.id.tv_searchresults_maleage
,R.id.tv_searchresults_place_city,R.id.tv_searchresults_country,R.id.tv_searchresults_gender,R.id.member_photo,R.id.rightarrow});
adapter.setViewBinder(new MyViewBinder());
setListAdapter(adapter);
lv=getListView();
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent,
View view, int position, long id) {
@SuppressWarnings("unchecked")
HashMap<String, String> o =
(HashMap<String, String>) lv.getItemAtPosition(position);
Toast.makeText(OnlineMembersActivity.this,
"ID '" + o.get("MainActivity.profile_id1") + "' was clicked.",
Toast.LENGTH_SHORT).show();
Intent i=new
Intent(OnlineMembersActivity.this,OnlineMemberProfileActivity.class);
i.putExtra("profile_id",
o.get("profile_id"));
//
MainActivity.Profile_id1=o.get("profile_id");
i.putExtra("username", o.get("username"));
i.putExtra("index",1);
startActivity(i);
}
});
class MyViewBinder implements ViewBinder {
public boolean setViewValue( View view, Object
data,String textRepresentation) {
if( (view instanceof ImageView) & (data
instanceof Bitmap) ) {
ImageView iv = (ImageView) view;
iv.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.i("Image", "Tapped");
}
});
Bitmap bm = (Bitmap) data;
iv.setImageBitmap(bm);
return true;
}
else if (view instanceof ImageView){
Log.i("Entered else", "Tapped");
final ImageView Img=(ImageView) view;
Img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
DemoPopupWindow dw = new DemoPopupWindow(v);
dw.showLikePopDownMenu();
Log.i("Image Button", "Tapped");
View vie=v.findFocus();
Log.i("Febi", "View id: "+vie);
View v2=vie.findFocus();
Log.i("Febi", "View id2: "+v2);
// String item=lv.getItemAtPosition(getSelectedItemPosition()).toString();
// Log.i("Febi", "Item: "+item);
}
});
}
return false;
}
}
class DemoPopupWindow extends BetterPopupWindow
implements OnClickListener {
public DemoPopupWindow(View anchor) {
super(anchor);
}
@Override
protected void onCreate() {
// inflate layout
LayoutInflater inflater =
(LayoutInflater)
this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup root = (ViewGroup)
inflater.inflate(R.layout.popup_grid_layout, null);
// setup button events
for(int i = 0, icount = root.getChildCount() ; i < icount
; i++) {
View v = root.getChildAt(i);
if(v instanceof TableRow) {
TableRow row = (TableRow) v;
for(int j = 0, jcount = row.getChildCount() ; j < jcount ;
j++) {
View item = row.getChildAt(j);
if(item instanceof Button) {
Button b = (Button) item;
b.setOnClickListener(this);
}
}
}
}
// set the inflated view as what we want to display
this.setContentView(root);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case(R.id.one):
Intent i=new
Intent(OnlineMembersActivity.this,MailToActivity.class);
i.putExtra("profile_id", MainActivity.Profile_id1);
startActivity(i);
Log.i("one s clicked", MainActivity.Profile_id1);
Toast.makeText(OnlineMembersActivity.this, "ID one was
clicked.", Toast.LENGTH_SHORT).show();
break;
case(R.id.two):
Toast.makeText(OnlineMembersActivity.this, "ID two
was clicked.", Toast.LENGTH_SHORT).show();
Log.i("two clicked","clicked");
break;
case(R.id.three):
// Intent i1=new
Intent(OnlineMembersActivity.this,ChatwithMemberActivity.class);
//startActivity(i1);
Toast.makeText(OnlineMembersActivity.this, "ID three
was clicked.", Toast.LENGTH_SHORT).show();
Log.i("three clicked","clicked");
break;
}
}
}
};
}
I need the corresponding listitem at which the popup button has been
clicked.....
On Tuesday, April 10, 2012 9:46:35 AM UTC+5:30, fredTechno wrote:
>
> Please post your code and logcat.
>
> On Mon, 2012-04-09 at 21:00 -0700, Febi.M.Felix Maliakkal wrote:
> > I have a listview..i am using simpleadapter to attach items to the
> > listview..along with the data within the list,i have an image
> > too.while clicking on the image, a popup menu will appear..(three
> > buttons within a table row)..while i click on any of these buttons
> > inside the popup menu ,,i need the correspoding list item...can any
> > one please help????
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to
> > [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
>
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en