Saturday, July 2, 2011

[android-developers] Re: problem with spinner.setOnItemClickListener

The error is related to the ADB and not to your code. Does a Hello
World app work for you?

On Jul 3, 7:41 am, אריאל <arielgordon...@gmail.com> wrote:
> Hello Everybody,
>
> Whats the problem with this code?
>
> private ListView lv1;
>  private String
> lv_arr[]={"Android","iPhone","BlackBerry","AndroidPeople","J2ME",
> "Listview","ArrayAdapter","ListItem","Us","UK","India"};
>  @Override
> public void onCreate(Bundle icicle)
>  {
> super.onCreate(icicle);
>  setContentView(R.layout.main);
> lv1=(ListView)findViewById(R.id.ListView01);
>  lv1.setAdapter(new
> ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
>  lv1.setTextFilterEnabled(true);
> lv1.setOnItemClickListener(new OnItemClickListener() {
>
> @Override
> public void onItemClick(AdapterView<?> arg0, View arg1, int position, long
> arg3) {
>  // TODO Auto-generated method stub
> AlertDialog.Builder adb=new
> AlertDialog.Builder(ListviewOnclickExample.this);
>  adb.setTitle("LVSelectedItemExample");
> adb.setMessage("Selected Item is = "+lv1.getItemAtPosition(position));
>  adb.setPositiveButton("Ok", null);
> adb.show();
>  }});
>
>  }
>
> i got this issue when i try  to run it
> [2011-07-03 02:30:05 - ddms]null
> java.lang.NullPointerException
> at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
>  at com.android.ddmlib.Client.sendAndConsume(Client.java:574)
> at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
>  at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
> at com.android.ddmlib.Client.getJdwpPacket(Client.java:671)
>  at
> com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:3­17)
> at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
>
> Thanks, Ariel.

--
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

No comments:

Post a Comment