Search in sources :

Example 96 with SimpleAdapter

use of android.widget.SimpleAdapter in project BlogSource by TeachCourse.

the class MainActivity method initData.

private void initData() {
    Intent intent = getIntent();
    String path = intent.getStringExtra(name);
    /*首次进入,path为空字符串*/
    if (path == null) {
        path = "";
    }
    mListView.setAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
    mListView.setTextFilterEnabled(true);
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent)

Example 97 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_packages_apps_Settings by crdroidandroid.

the class ZonePickerTest method testConstructTimeZoneAdapter.

@Test
public void testConstructTimeZoneAdapter() {
    final SimpleAdapter adapter = ZonePicker.constructTimezoneAdapter(RuntimeEnvironment.application, true);
    assertThat(adapter).isNotNull();
    ViewGroup parent = new FrameLayout(RuntimeEnvironment.application);
    ViewGroup convertView = new FrameLayout(RuntimeEnvironment.application);
    TextView text1 = new TextView(RuntimeEnvironment.application);
    text1.setId(android.R.id.text1);
    convertView.addView(text1);
    TextView text2 = new TextView(RuntimeEnvironment.application);
    text2.setId(android.R.id.text2);
    convertView.addView(text2);
    adapter.getView(0, convertView, parent);
    final CharSequence text = text2.getText();
    assertThat(text).isInstanceOf(Spanned.class);
    final TtsSpan[] spans = ((Spanned) text).getSpans(0, text.length(), TtsSpan.class);
    // GMT offset label should have TTS spans
    assertThat(spans.length).isGreaterThan(0);
}
Also used : TtsSpan(android.text.style.TtsSpan) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) SimpleAdapter(android.widget.SimpleAdapter) TextView(android.widget.TextView) Spanned(android.text.Spanned) Test(org.junit.Test)

Example 98 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_packages_apps_Settings by crdroidandroid.

the class ZonePicker method constructTimezoneAdapter.

/**
 * Constructs an adapter with TimeZone list. Sorted by TimeZone in default.
 *
 * @param sortedByName use Name for sorting the list.
 */
public static SimpleAdapter constructTimezoneAdapter(Context context, boolean sortedByName, int layoutId) {
    final String[] from = new String[] { ZoneGetter.KEY_DISPLAY_LABEL, ZoneGetter.KEY_OFFSET_LABEL };
    final int[] to = new int[] { android.R.id.text1, android.R.id.text2 };
    final String sortKey = (sortedByName ? ZoneGetter.KEY_DISPLAY_LABEL : ZoneGetter.KEY_OFFSET);
    final MyComparator comparator = new MyComparator(sortKey);
    final List<Map<String, Object>> sortedList = ZoneGetter.getZonesList(context);
    Collections.sort(sortedList, comparator);
    final SimpleAdapter adapter = new SimpleAdapter(context, sortedList, layoutId, from, to);
    adapter.setViewBinder(new TimeZoneViewBinder());
    return adapter;
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 99 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_packages_apps_Settings by crdroidandroid.

the class ZonePicker method setSorting.

private void setSorting(boolean sortByTimezone) {
    final SimpleAdapter adapter = sortByTimezone ? mTimezoneSortedAdapter : mAlphabeticalAdapter;
    setListAdapter(adapter);
    mSortedByTimezone = sortByTimezone;
    final int defaultIndex = getTimeZoneIndex(adapter, TimeZone.getDefault());
    if (defaultIndex >= 0) {
        setSelection(defaultIndex);
    }
}
Also used : SimpleAdapter(android.widget.SimpleAdapter)

Example 100 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_packages_apps_Settings by LineageOS.

the class ZoneList method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    String[] from = new String[] { KEY_DISPLAYNAME, KEY_GMT };
    int[] to = new int[] { android.R.id.text1, android.R.id.text2 };
    MyComparator comparator = new MyComparator(KEY_OFFSET);
    List<HashMap> timezoneSortedList = getZones();
    Collections.sort(timezoneSortedList, comparator);
    mTimezoneSortedAdapter = new SimpleAdapter(this, (List) timezoneSortedList, android.R.layout.simple_list_item_2, from, to);
    List<HashMap> alphabeticalList = new ArrayList<HashMap>(timezoneSortedList);
    comparator.setSortingKey(KEY_DISPLAYNAME);
    Collections.sort(alphabeticalList, comparator);
    mAlphabeticalAdapter = new SimpleAdapter(this, (List) alphabeticalList, android.R.layout.simple_list_item_2, from, to);
    // Sets the adapter
    setSorting(true);
    // If current timezone is in this list, move focus to it
    setSelection(mDefault);
    // Assume user may press Back
    setResult(RESULT_CANCELED);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleAdapter(android.widget.SimpleAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

SimpleAdapter (android.widget.SimpleAdapter)133 HashMap (java.util.HashMap)52 ListView (android.widget.ListView)38 Intent (android.content.Intent)34 Map (java.util.Map)33 View (android.view.View)28 ArrayList (java.util.ArrayList)28 AdapterView (android.widget.AdapterView)27 TextView (android.widget.TextView)26 ViewGroup (android.view.ViewGroup)13 ListAdapter (android.widget.ListAdapter)10 ImageView (android.widget.ImageView)8 Spanned (android.text.Spanned)6 TtsSpan (android.text.style.TtsSpan)6 FrameLayout (android.widget.FrameLayout)6 Test (org.junit.Test)6 SuppressLint (android.annotation.SuppressLint)5 Context (android.content.Context)5 MotionEvent (android.view.MotionEvent)5 OnClickListener (android.view.View.OnClickListener)5