Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Arbitrarily Nested ListView Type Menu

I want to create something like this:

widget demo

That is, a menu which I can feed an arbitrarily nested tree of strings to which will then lead to an activity who has access to the selected item.

Should I create an activity class TreeSelectActivity then pass it a List<TreeNode> in a bundle and then recursively create a list of the next activities for each item? One activity per item doesn't seem like the correct way of doing this. Maybe it would be better if they were fragments?

What are the pros and cons of different approaches to do this, and which approach is easiest to implement?

like image 642
Ell Avatar asked Jul 14 '13 21:07

Ell


People also ask

How to use a nested array in Android listview?

How to use nested array in android listview? This example demonstrate about How to use a nested array in android listview. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml.

What is next page in Android listview?

Next Page. Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.

How to display an array of strings in listview using arrayadapter?

By default, ArrayAdapter creates a view for each array item by calling toString () on each item and placing the contents in a TextView. Consider you have an array of strings you want to display in a ListView, initialize a new ArrayAdapter using a constructor to specify the layout for each string and the string array −

What are the attributes of listview in Android?

ListView Attributes Sr.No Attribute & Description 1 android:id This is the ID which uniquely ... 2 android:divider This is drawable or colo ... 3 android:dividerHeight This specifies hei ... 4 android:entries Specifies the reference ... 2 more rows ...


1 Answers

Look into Wizard Pager to see if this does what you need.

Otherwise, you could implement it as an activity that takes a tree and has an adapter that shows its current level, and then passes subtrees to new activities via intent extras.

Or you could implement it as a Fragment that does approximately the same thing and stay in the same activity and just do FragmentTransactions.

like image 166
Kevin Avatar answered Oct 20 '22 18:10

Kevin