• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Passing Intents to start Activities

Hey guys.

I'm trying to make a program where you start out with a grid of pictures. I got it working to the point where if you tap one of the pictures, a RelativeLayout with some text (a different activity that uses a separate layout depending on which picture you pressed) opens up. What I CAN'T get to work is to get the grid to open up a GalleryLayout or ListView. Both ways have force closed any time I try to press one of the pictures. I'm passing an Intent and using startActivity() [which worked for the RelativeLayout] but it won't work for RelativeLayout or GalleryLayout.

Help?

Thanks!
 
I have never personally used a gallery layout, but for a ListView, have you tried extending ListActivity instead of the usual Activity class?

the ListActivity class contains all of the functionality of a standard Activity class with some extra implementations for ListViews. It eases the process greatly.

Here is an example implementation:

public class MitsuMediaGUI extends ListActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);



}

@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l,v,position,id);

if(position == 0)
{
startActivity(new Intent(MitsuMediaGUI.this,RoTM.class));
}
...

}
}
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones