beginner to android <><>superheroe probem>>>

Put your problem here if it does not fit any of the other categories.

beginner to android <><>superheroe probem>>>

Postby edward_park » Sun Jan 16, 2011 12:53 pm

]={"Batman","Captain America","Superman","Spiderman","Green Lantern","The Hulk","Wonder Woman","Wolverine","Punisher"};
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
spr=(ListView)findViewById(R.id.ListView01);
spr.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , lv_arr));
}
}[/code]

can any1 plz help me out need it little urgent.....
thnk u
Last edited by edward_park on Tue Jan 18, 2011 10:43 am, edited 1 time in total.
edward_park
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Jan 16, 2011 10:32 am

Top

Re: beginner to android <><>superheroe problem>>>

Postby Skiller » Sun Jan 16, 2011 1:51 pm

What you need is something like the following code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. spr.setOnItemClickListener(new OnItemClickListener()
  2. {
  3.         public void onItemClick(AdapterView<?> parent, View view, int position, long id)
  4.         {
  5.                 //Check which item was clicked from position or id and start the appropriate activity here
  6.         }
  7. });
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


If you need to know how to start the activity I'm not really sure myself as I haven't tried using multiple activities in the same app yet, but I believe you do it via Intents (http://developer.android.com/reference/android/content/Intent.html).
Skiller
Developer
Developer
 
Posts: 33
Joined: Sun Nov 28, 2010 8:35 pm
Location: Australia

Re: beginner to android <><>superheroe problem>>>

Postby edward_park » Sun Jan 16, 2011 2:26 pm

@skiller got confuss...wgat is multiple activities???...
edward_park
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Jan 16, 2011 10:32 am

Re: beginner to android <><>superheroe problem>>>

Postby Skiller » Sun Jan 16, 2011 7:09 pm

Multiple activities = more than one Activity.
Skiller
Developer
Developer
 
Posts: 33
Joined: Sun Nov 28, 2010 8:35 pm
Location: Australia

Re: beginner to android <><>superheroe problem>>>

Postby edward_park » Sun Jan 16, 2011 7:24 pm

@skiller
m quite confuse on selecting array string,....
i tried, but the m not getting what i really want,
there are tutorial only for the toast
there is no tutorial on new activity from listview...
edward_park
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Jan 16, 2011 10:32 am

Re: beginner to android <><>superheroe problem>>>

Postby Skiller » Sun Jan 16, 2011 8:58 pm

Check out this link to see how to start a new activity: http://developer.android.com/guide/appendix/faq/commontasks.html#opennewscreen

Just put the code to start your other activity into the onItemClick function of the OnItemClickListener in the code I posted earlier. The position variable in that function should be the index of the selected string which should also correspond to the index of the string in your string array.
Skiller
Developer
Developer
 
Posts: 33
Joined: Sun Nov 28, 2010 8:35 pm
Location: Australia

Top

Re: beginner to android <><>superheroe problem>>>

Postby edward_park » Mon Jan 17, 2011 8:29 pm

thnkz,
edward_park
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Jan 16, 2011 10:32 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 17 guests