Can you have a GridView and a ListView in one XML/Activity?
I'm trying to load both and its giving me a Null Pointer exception,
but doesn't tell me why pretty much
What i'm trying to do is have a top level menu (GridView) and List of
Menu Options below (ListView).
Here is an example code:
public class NewsReaderMainActivity extends Activity {
GridView topLevelList;
ListView newsCategoryList;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] newsSourceArray = getResources().getStringArray(
R.array.newssource);
setContentView(R.layout.newsreadermain);
newsCategoryList = (ListView) findViewById(R.id.categoryList);
topLevelList = (GridView) this.findViewById(R.id.topMenuList);
ArrayAdapter<String> newsSource = new ArrayAdapter<String>(this,
R.layout.newsgridtypeitem, newsSourceArray);
topLevelList.setAdapter(newsSource);
String[] newsCategoryArray = getResources().getStringArray(
R.array.newspapers);
ArrayAdapter<String> newsCategory = new
ArrayAdapter<String>(this,
R.layout.newslistcategoryitem,
newsCategoryArray);
newsCategoryList.setAdapter(newsCategory);
}
}
On Sat, Jun 26, 2010 at 5:53 PM, Mark Murphy <[email protected]> wrote:
> On Sat, Jun 26, 2010 at 4:36 PM, Dave Germiquet <[email protected]>
> wrote:
>> I'm trying to create a list of clickable items that will go to the
>> side instead of on the next line. (I was thinking I want a listview)
>>
>> For example I want to do a menu bar like this:
>>
>> MenuItem1 MenuItem2 MenuItem3 MenuItem4
>> ---
>> Some Text/Menu Items as well
>> ----
>>
>> However when ever I do a list view each item goes on its own line like this
>>
>> "MenuItem1"
>> "MenuItem2"
>> "MenuItem3"
>>
>> Any suggestions on how to do this?
>
> Don't use a ListView. Try a GridView.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Training...At Your Office: http://commonsware.com/training
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> 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
>
--
Dave Germiquet
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
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