Search in sources :

Example 91 with SimpleAdapter

use of android.widget.SimpleAdapter in project MyApp by MatthewDevelop.

the class ContactActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_contact);
    ButterKnife.bind(this);
    final List<Map<String, String>> list = readContact();
    LogUtil.e(TAG, list.toString());
    contactList.setAdapter(new SimpleAdapter(this, list, R.layout.contact_list_item, new String[] { "name", "phone" }, new int[] { R.id.tv_name, R.id.tv_phone }));
    contactList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // 将数据返回
            String phone = list.get(position).get("phone");
            Intent intent = new Intent();
            intent.putExtra("phone", phone);
            setResult(RESULT_OK, intent);
            finish();
        }
    });
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) HashMap(java.util.HashMap) Map(java.util.Map) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 92 with SimpleAdapter

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

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 93 with SimpleAdapter

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

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 94 with SimpleAdapter

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

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 95 with SimpleAdapter

use of android.widget.SimpleAdapter in project Virtualview-Android by alibaba.

the class ScrollerListActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(android.R.layout.list_content);
    List<Map<String, String>> list = new ArrayList<Map<String, String>>();
    HashMap<String, String> scroll0 = new HashMap<String, String>();
    scroll0.put("name", "ScrollerVL");
    scroll0.put("desp", "orientation = V | mode = linear");
    scroll0.put("class", ComponentActivity.class.getName());
    scroll0.put("data", "component_demo/slider_item.json");
    list.add(scroll0);
    HashMap<String, String> scroll1 = new HashMap<String, String>();
    scroll1.put("name", "ScrollerVS");
    scroll1.put("desp", "orientation = V | mode = staggered");
    scroll1.put("class", ComponentActivity.class.getName());
    scroll1.put("data", "component_demo/slider_item.json");
    list.add(scroll1);
    HashMap<String, String> scroll2 = new HashMap<String, String>();
    scroll2.put("name", "ScrollerH");
    scroll2.put("desp", "orientation = H");
    scroll2.put("class", ComponentActivity.class.getName());
    scroll2.put("data", "component_demo/slider_item.json");
    list.add(scroll2);
    ListAdapter listAdapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_2, new String[] { "name", "desp" }, new int[] { android.R.id.text1, android.R.id.text2 });
    setListAdapter(listAdapter);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleAdapter(android.widget.SimpleAdapter) HashMap(java.util.HashMap) Map(java.util.Map) ListAdapter(android.widget.ListAdapter)

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