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