R
R
relgames2011-11-02 18:35:10
Android
relgames, 2011-11-02 18:35:10

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

7 answer(s)
A
Alibobaevich, 2011-11-02
@alibobaevich

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" />

H
Hitory, 2011-11-02
@Hitory

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

A
Alexey Grichenko, 2011-11-02
@Kalobok

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.

E
Evengard, 2011-11-03
@Evengard

developer.android.com/resources/articles/layout-tricks-efficiency.html
Wrong?

P
palmut, 2011-11-03
@palmut

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 }));
  }

}

And this is the mail.xml layout code:
<?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>

R
relgames, 2011-11-02
@relgames

It seems like I found a solution developer.android.com/reference/android/app/ListActivity.html
I'll keep looking...

R
relgames, 2011-11-03
@relgames

As a result, I did everything using the copy-paste method (stupidly manually set the layout), I have the number of elements in the list and their names are known in advance, only the values ​​\u200b\u200bof the elements change dynamically.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question