hi,
I wrote a simple program using SimpleAdapter to populate list view .To
do this i modified the existing notepad example and try using
onKeyDown instead of onCreateOptionMenu .Here i can activate the
onKeyDown method for first time only,for the second press, on the
appropriate key, the onKeyDown is not called ,I can say this from
logcat output.I could not guess the reason .Any clarification on this
is appreciable.
this is my code
public class SimpleAdapter1 extends ListActivity {
/** Called when the activity is first created. */
ArrayList<HashMap<String,String>> arr = new
ArrayList<HashMap<String,String>>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SimpleAdapter sim =new SimpleAdapter(this,
arr,
R.layout.main1,
new String[] {"list1","list2"},
new int[] {R.id.list1,R.id.list2});
Log.d(getClass().getSimpleName(),"In onCreate");
setListAdapter(sim);
}
public boolean onKeyDown(int keyCode, KeyEvent ev)
{
switch(keyCode)
{
case KeyEvent.KEYCODE_DPAD_CENTER:
Log.v("SimpleAdapter","Key DPAD CENTER pressed");
press();
return true;
default:
return false;
}
}//onkeyDown
public void press()
{
long timel=System.currentTimeMillis();
Log.d("Current time is : " ,Long.toString(timel));
HashMap<String,String> hm=new HashMap<String,String>();
hm.put("list2", Long.toString(timel));
hm.put("list1", "Now Time is :");
a.add(hm);
SimpleAdapter sim1 =new SimpleAdapter(this,a,R.layout.main1,new
String[] {"list1","list2"},new int[] {R.id.list1,R.id.list2});
setListAdapter(sim1);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---