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