I want to create list view just like this: http://dl.maximumpc.com/galleries/androidpower/Alarm_full.jpg
I need to create view like on second and fourth screens. As for fourth screen, it seems that each row has it's own layout...
I've searched Internet and even downloaded alarm source code from git repository, but it doesn't contains what I want. Any help would be useful. Thanks!
The second screen is pretty straightforward. It's basically a RelativeLayout with a full-width button at the top and a listview. The listview items will use a custom layout e.g. a RelativeLayout with a Button showing the time, a TextView to show the description, a TextView to show the selected days and a CheckBox to indicate selection. The fourth screen looks like a preference activity which can be built up from an xml file and/or custom preferences.
Yes, as John J Smith said, it's not very complicated. And i'm sure there are many articles on Internet about how to build a custom list view(at least there're many in China).
And here is a general way to do this:
To custom a list view, follow these ways in general:
1. create your own list adapter, usually extends BaseAdapter, write getView method etc;
2. bind your adapter to a list view;
3. write a layout file implements your list view item, and bind data in your adapter.
Especially, if your custom list view item has a button/checkbox/etc, you'll need more work.
Related
My problem is simple: I need to make a layout similar to android.R.layout.simple_expandable_list_item_1 which can fit more than one textview in the layout, as well as show the little '>' symbol that indicates that the tab is expandable.
How can this best be accomplished? My first thought was to use the layout as a background of a linear layout with two textviews in it, but I can't seem to make that work.
Vogella has a pretty good tutorial on how to achieve custom list views through Adapters.
Basically, what you do is you create a Layout with the looks you want for the list items and then you extend an adapter (ArrayAdapter for instance), see section 4. Then, in your activity, you create an instance of your Adapter implementation and populate it from an Array containing the data for the list.
Also have a look at the Developers site for how to make the list scroll smoothly with the ViewHolder pattern.
And if you feel you need more info on the expandable part maybe the hive can help.
First I have build a simple android application which had only five optios to select. For this purpose I used five Buttons on main Activity. Now I have more than twenty buttons in a ScrollView to select. What is the best way to represent this kind of application (using buttons in a ScrollView? using TabHost? or with some other widget?)
The app look like this now:
Grid View or List View or Recycler View
the Adapter automatically will add buttons with the names you want, something that I did for my upcoming app.
I made a java class called data which has 'data` for my app.
it has an array of images for my GridView.
SO:
Make a class called data
Add a public final static String[] myArray array of your names, or data
Now, whenever you want to access them, use data.myArray
If you want to access one item ,use data.myArray[itemIndex]
Don't forget, indexes are zero based, not 1
Put your button inside a viewHolder class
find the id of the button in the getView if convertView is null & set the holder as a tag
NOTE : after finding the ID of the button, just leave it don't do anything or edit the text, continue reading please.
Use that array with your custom adapter
as
gridView.setAdapter(new myCustomAdapter(parameter1, parameter2,data.myArray);
use this , I just made it yesterday, added array of buttons feature now. You can just learn it or use it or commit changes.
NOTE :
You can make an array of listeners just like any primitive data type, View.OnClickListener[] and name it, initialize it.
Use grid view. it will be easy to show multiple buttons on screen using grid view.
I have the following prototype:
What is the way to list views in a scroll-able way in a screen?
What I have already tried:
I tried to create a class and extends the LinearLayout class and dynamically adds my Views (the compound controls class is my view also extends LinearLayout) to the main LinearLayout. So I got a list of my views which is scroll-able.
I'm not sure what you mean, but looking at what you have tried, what's wrong with using a ListView? As the name implies, it should do exactly what you want:
What is the way to list views in a scroll-able way in a screen?
Here is a quote from the android documentation of a ListView
ListView is a view group that displays a list of scrollable items. The
list items are automatically inserted to the list using an Adapter
that pulls content from a source such as an array or database query
and converts each item result into a view that's placed into the list.
You should be able to add a ListView directly as a sub-view under your LinearLayout.
your questions seems like hard to understand.
did you mean how to set the whole page(activity) into a listview?
listviews are scrollable in default (of course, you can see it if the list is long enough and you can set the whole activity as a list).. you can customize it also by using templates (xml)
and extending ArrayAdapter of your type (let's say ArrayAdapter<UpcomingEvents>) and supply data from db...
is this what you mean?
I am trying to create a screen where I get two items from SharedPreferences and display them to the screen, and then display a list via an adapter.
What I am not sure about is how to structure the layout xml file for this. Any suggestions how to do that?
Thanks!
You can have the main layout with a listview. Then you can have a sub layout for each row of your list. This row layout, let's call it row_layout.xml may have two text areas if your items are text or it may have a text area and a checkbox button if that's what you want. Basically, whatever you want to display in a single row of your list.
Read up a tutorial, here's one: http://www.vogella.de/articles/AndroidListView/article.html
Take a look # MergeAdapter, you can also create a view only listitem and add these item as header to the list
I am not sure what you mean. Are you asking for examples of layouts with two textviews that can be updated via sharedprefs, with a ListView in the activity? Or just suggestions? An easy way to get started would be to use the Eclipse Android plugin that has a layout designer in it. Here is a tutorial on how to use it http://mobile.tutsplus.com/tutorials/android/android-layout/ Its pretty easy and straight forward.
We are developing an Android project. In that project we need to create a list view with multiple objects.
Inside each list view item we need to show Name, Mobile, Checkbox1 and Checkbox2
We tried with various options and we are clue less how to get this done.
You can create an .xml file, which contains a Layout (LinearLayout, RelativeLayout etc) and inside that layout put some Views like TextViews for the Name and Mobile and 2 CheckBox items for your checkboxes. I recommend this tutorial for more on ListView issues.
You need to define your own row layout and also your own ListAdapter implementation. The adapter needs to override getView to return your custom row view. There's a good example here that extends an ArrayAdapter. There's another example here that extends a CursorAdapter. Search the web for android custom listview row to get lots of other examples.