Monday, November 8, 2010

[android-developers] Re: Problem with context menu

Thanks for ur reply,

In my app, table rows are created dynamically by using thread and
handler as

Handler dataHandler = new Handler(){

public void handleMessage(Message msg){
/* Create the table row */
TableRow tr = new TableRow(getBaseContext());
registerForContextMenu(tr);
........
.........
}
private class LoadingDataThread extends Thread{
Handler handler;
LoadingDataThread(Handler handler){
this.handler = handler;
}
public void run(){
try{
//creates JSONObject
albumsJSONObject =
MyJSON.getJSONObject(intent.getStringExtra("JSONAlbumsData"));

if(albumsJSONObject!=null){
albumsJSONArray = albumsJSONObject.getJSONArray("album");

noOfAlbums = albumsJSONArray.length();

//create dynamic rows
for(int i=0;i<noOfAlbums;i++){

handler.sendMessage(handler.obtainMessage());
}
}
}
}

I have created context menu by using xml file as

@Override
public void onCreateContextMenu(ContextMenu menu,View
v,ContextMenuInfo menuInfo){
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.album_contextmenu, menu);
}

when we click on any context menu item the below method is called

public boolean onContextItemSelected(MenuItem item){
ContextMenuInfo info = item.getMenuInfo();
}

But that 'info' object gets 'null' value, Actually this 'info.id'
gives the selected table row id.
i dont know why it is happening like that. If anyone knows about this
please guide me.

thanks
venu

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate