Answer the question
In order to leave comments, you need to log in
Android development: how to make an Activity like Settings -> About phone -> General information?
I rummaged through a bunch of documentation, I can’t figure out how to do the simplest task: you need to draw a caption-value list so that it’s like in a standard application Settings -> About phone -> General information ( example )
It seems like this is a ListView, in theory, what kind of -an adapter, but standard adapters draw a list of 1 value, and I have 2 values - one title, in a large font, and another in a small font. It turns out that you need to write your own adapter, plus you need to write your own xml for the string ... It's strange that there are a lot of actions for what looks like a standard element of the system (I've seen such a list in many places).
The task seems to be simple, but here’s a stupor, I can’t figure something out ...
Answer the question
In order to leave comments, you need to log in
can
in
the
standard
way
:
developer.android.com/reference/android/preference/PreferenceScreen.html _ _
_ title="Prevent from sleeping"
android:summary="keep the screen On"
android:defaultValue="true"
/>
Of course, I'm far from being an expert on the platform, but here's what I could come up with: -
All the same, write your own adapter using your class with Map
- Make two lists. In one, the lines that are passed to the ListView adapter, and in the second, the lines that are selected in the adapter's getView
If you really don't feel like writing it yourself, you can try the standard adapter with standard layouts:
developer.android.com/reference/android/R.layout.html#simple_list_item_2
I haven't tried it myself, so I can't promise that it will work. But judging by the references in various examples, this is exactly what you need.
developer.android.com/resources/articles/layout-tricks-efficiency.html
Wrong?
But this option is not suitable?
This is the activation code:
public class TestActivity extends ListActivity {
private final static String TITLE_KEY = "title";
private final static String DESCRIPTION_LEY = "description";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
int count = 10;
for (int i = 1; i <= count; i++) {
final HashMap<String, String> item = new HashMap<String, String>();
item.put(TITLE_KEY, String.format("Title %d", i));
item.put(DESCRIPTION_LEY, String.format("Description %d", i));
data.add(item);
}
setListAdapter(new SimpleAdapter(this, data, android.R.layout.simple_list_item_2, new String[] { TITLE_KEY,
DESCRIPTION_LEY }, new int[] { android.R.id.text1, android.R.id.text2 }));
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No data" />
</LinearLayout>
It seems like I found a solution developer.android.com/reference/android/app/ListActivity.html
I'll keep looking...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question