android.widget.SimpleAdapter Java Examples

The following examples show how to use android.widget.SimpleAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 6 votes vote down vote up
/**
 * Creates ListAdapter populated with the list of nearby places.
 *
 * @param places the list of nearby places used to populate the adapter.
 * @return an adapter populated with the list of nearby places.
 */
private ListAdapter createPlaceListAdapter(List<PlaceInfo> places) {
  final double kilometersInAMile = 1.60934;
  List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
  for (PlaceInfo place : places) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("placeIcon", R.drawable.ic_launcher);
    map.put("placeName", place.getName());
    map.put("placeAddress", place.getAddress());
    String distance = String.format(
        getString(R.string.distance), place.getDistanceInKilometers(),
        place.getDistanceInKilometers() / kilometersInAMile);
    map.put("placeDistance", distance);
    data.add(map);
  }

  SimpleAdapter adapter = new SimpleAdapter(MainActivity.this, data, R.layout.place_item,
      new String[] {"placeIcon", "placeName", "placeAddress", "placeDistance"},
      new int[] {R.id.place_Icon, R.id.place_name, R.id.place_address, R.id.place_distance});

  return adapter;
}
 
Example #2
Source File: InfoActivity.java    From protrip with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_info);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_info);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(getString(R.string.title_titlebar_info));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);


    initList();
    ListView lv = (ListView) findViewById(R.id.list_info);
    SimpleAdapter simpleAdpt = new SimpleAdapter(this, infoList, android.R.layout.simple_list_item_1,
            new String[] {"info"}, new int[] {android.R.id.text1});

    lv.setAdapter(simpleAdpt);
    lv.setOnItemClickListener(this);
    lv.setSelection(0);

    //views
    TextView tvVersionName=(TextView)findViewById(R.id.label_version);
    tvVersionName.setText("v"+BuildConfig.VERSION_NAME);
}
 
Example #3
Source File: ListViewActivity.java    From Rocko-Android-Demos with Apache License 2.0 6 votes vote down vote up
private void init() {
        listView = (ListView) findViewById(R.id.list_view);

        String[] strs = getData(100);
        List<Map<String, Object>> list = new ArrayList<>();
        for (String str : strs) {
            Map<String, Object> map = new HashMap<>();
            map.put("text", str);
            list.add(map);
        }
        SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.item_simple, new String[]{"text"}, new int[]{R.id.text_view});
        listView.setAdapter(adapter);

        AutoScrollHelper autoScrollHelper = new ListViewAutoScrollHelper(listView);
        listView.setOnTouchListener(autoScrollHelper);
        autoScrollHelper.setEnabled(true);
//        autoScrollHelper.setActivationDelay(3000);
//        autoScrollHelper.setRampDownDuration(3000);
        Toast.makeText(this, "长按上或下边缘", Toast.LENGTH_SHORT).show();
    }
 
Example #4
Source File: BreadcrumbsAdapter.java    From BreadcrumbsView with MIT License 6 votes vote down vote up
@Override
public void setItem(@NonNull IBreadcrumbItem item) {
	super.setItem(item);
	imageButton.setClickable(item.hasMoreSelect());
	if (item.hasMoreSelect()) {
		List<Map<String, String>> list = new ArrayList<>();
		for (Object obj : item.getItems()) {
			Map<String, String> map = new HashMap<>();
			map.put("text", obj.toString());
			list.add(map);
		}
		ListAdapter adapter = new SimpleAdapter(getPopupThemedContext(), list, R.layout.breadcrumbs_view_dropdown_item, new String[] {"text"}, new int[] {android.R.id.text1});
		popupWindow.setAdapter(adapter);
		popupWindow.setWidth(ViewUtils.measureContentWidth(getPopupThemedContext(), adapter));
		imageButton.setOnTouchListener(popupWindow.createDragToOpenListener(imageButton));
	} else {
		imageButton.setOnTouchListener(null);
	}
}
 
Example #5
Source File: EmailListActivity.java    From androidmooc-clase1 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_email_list);
	
	Button btnAdd = (Button)findViewById(R.id.btnAdd);
	btnAdd.setOnClickListener(this);
	
	SimpleAdapter adapter = new SimpleAdapter(this, 
								emails, 
								android.R.layout.simple_list_item_2, 
								new String[] {EMAIL, DATE_ADDED}, 
								new int[] {android.R.id.text1, 
										   android.R.id.text2 });	
	setListAdapter(adapter);
}
 
Example #6
Source File: BuyTicketInfoFragment.java    From Huochexing12306 with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View v = inflater.inflate(R.layout.fragment_buy_ticket_info, null);
	lvInfos = (ListView) v.findViewById(R.id.buyTicketInfo_lvInfos);
	MyDatabase myDB = new MyDatabase(this.getActivity());
	mAdapter= new SimpleAdapter(this.getActivity(), mLstDatas, R.layout.item_buy_ticket_info,
			new String[]{MyDatabase.KEY, MyDatabase.VALUE},
			new int[]{R.id.item_buy_ticket_info_tvQuestion, R.id.item_buy_ticket_info_tvAnswer}
			);
	lvInfos.setAdapter(mAdapter);
	myDB.closeDB();
	notifyAdapterDataChanged(myDB.getTicketInfos(0));
	MyUtils.setListViewHeightBasedOnChildren(lvInfos);  //设置ListView全部显示
	ViewGroup.LayoutParams params = lvInfos.getLayoutParams();
	
	params.height += 3000;   //方法不太准,人为校正高度
	lvInfos.setLayoutParams(params);
	sv1 = (ScrollView)v.findViewById(R.id.buyTicketInfo_sv1);
	sv1.smoothScrollTo(0, 20);
	return v;
}
 
Example #7
Source File: MultiSelectListPreferenceCompat.java    From MaterialPreferenceCompat with MIT License 6 votes vote down vote up
@Override
public void setEntries(CharSequence[] entries) {
	super.setEntries(entries);
	if (mDialog != null) {
		ArrayList<HashMap<String, CharSequence>> listItems = new ArrayList<>();
		for (CharSequence entry : entries) {
			HashMap<String, CharSequence> map = new HashMap<>();
			map.put("item", entry);
			listItems.add(map);
		}
		mDialog.getListView().setAdapter(new SimpleAdapter(
				mContext,
				listItems,
				R.layout.select_dialog_singlechoice_material,
				new String[] {"item"},
				new int[]{android.R.id.text1}
		));
	}
}
 
Example #8
Source File: ScriptListActivity.java    From Virtualview-Android with MIT License 6 votes vote down vote up
@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> ntext = new HashMap<String, String>();
    ntext.put("name", "this.name = (data.time > data.id) && (data.time >= 3)");
    list.add(ntext);
    HashMap<String, String> page = new HashMap<String, String>();
    page.put("name", "PageScrollScript");
    page.put("class", ComponentActivity.class.getName());
    page.put("data", "component_demo/page_item.json");
    list.add(page);
    HashMap<String, String> click = new HashMap<String, String>();
    click.put("name", "ClickScript");
    click.put("class", ComponentActivity.class.getName());
    list.add(click);
    ListAdapter listAdapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1});
    setListAdapter(listAdapter);
}
 
Example #9
Source File: PlaceDetailsActivity.java    From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 6 votes vote down vote up
/**
 * Creates ListAdapter populated with offer information.
 *
 * @param offers the list of offers used to populate the adapter.
 * @return an adapter populated with offer information.
 */
private ListAdapter createOfferListAdapter(List<Offer> offers) {
  List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
  for (Offer offer : offers) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("offerIcon", offer.getImageUrl());
    map.put("offerTitle", offer.getTitle());
    map.put("offerDetails", offer.getDescription());
    data.add(map);
  }

  SimpleAdapter adapter = new SimpleAdapter(PlaceDetailsActivity.this, data,
      R.layout.offer_item, new String[] {"offerIcon", "offerTitle", "offerDetails"},
      new int[] {R.id.offer_Image, R.id.offer_name, R.id.offer_description});
  adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
  return adapter;
}
 
Example #10
Source File: ListActivity.java    From BackgroundLibrary with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    //不需要任何特殊处理
    ListView listView = findViewById(R.id.listView);
    for (int i = 0; i < 20; i++) {
        data.add(new HashMap<String, Object>());
    }
    SimpleAdapter simAdapt = new SimpleAdapter(
            this,
            data,
            R.layout.item,
            new String[]{},// 与下面数组元素要一一对应
            new int[]{});
    listView.setAdapter(simAdapt);
}
 
Example #11
Source File: AlertList.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
void FillLists() {
    // We use a - sign to tell that this text should be stiked through
    SimpleAdapter.ViewBinder vb = new SimpleAdapter.ViewBinder() {
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            TextView tv = (TextView) view;
            tv.setText(textRepresentation.substring(1));
            if (textRepresentation.substring(0, 1).equals("-")) {
                tv.setPaintFlags(tv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            }
            return true;
        }
    };

    ArrayList<HashMap<String, String>> feedList;
    feedList = createAlertsMap(false);
    SimpleAdapter simpleAdapterLow = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
    simpleAdapterLow.setViewBinder(vb);

    listViewLow.setAdapter(simpleAdapterLow);

    feedList = createAlertsMap(true);
    SimpleAdapter simpleAdapterHigh = new SimpleAdapter(this, feedList, R.layout.row_alerts, new String[]{"alertName", "alertThreshold", "alertTime", "alertMp3File", "alertOverrideSilenceMode"}, new int[]{R.id.alertName, R.id.alertThreshold, R.id.alertTime, R.id.alertMp3File, R.id.alertOverrideSilent});
    simpleAdapterHigh.setViewBinder(vb);
    listViewHigh.setAdapter(simpleAdapterHigh);
}
 
Example #12
Source File: StarCharacterActivity.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
private void loadGridData() {
    saImageItems = new SimpleAdapter(this,
            StarSignConstant.getGridViewData(),
            R.layout.grid_view_item,
            new String[]{StarSignConstant.IMAGE_ITEM, StarSignConstant.TEXT_ITEM
                    , StarSignConstant.DATE_ITEM},
            new int[]{R.id.itemImage, R.id.itemText, R.id.itemDate});


    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            sendLoadMsg();
        }
    }).start();
}
 
Example #13
Source File: MainActivity.java    From MobileShoppingAssistant-sample with Apache License 2.0 6 votes vote down vote up
/**
 * Creates ListAdapter populated with the list of nearby places.
 * @param placesRetrieved the list of places to put in the adapter.
 * @return an adapter populated with the list of nearby places.
 */
private ListAdapter createPlaceListAdapter(final List<PlaceInfo>
        placesRetrieved) {
    final double kilometersInAMile = 1.60934;
    List<Map<String, Object>> data = new ArrayList<>();
    for (PlaceInfo place : placesRetrieved) {
        Map<String, Object> map = new HashMap<>();
        map.put("placeIcon", R.drawable.ic_shopping_cart_black_48dp);
        map.put("placeName", place.getName());
        map.put("placeAddress", place.getAddress());
        String distance = String.format(
                getString(R.string.distance),
                place.getDistanceInKilometers(),
                place.getDistanceInKilometers() / kilometersInAMile);
        map.put("placeDistance", distance);
        data.add(map);
    }

    return new SimpleAdapter(MainActivity.this, data,
            R.layout.place_item,
            new String[]{"placeIcon", "placeName", "placeAddress",
                    "placeDistance"},
            new int[]{R.id.place_Icon, R.id.place_name,
                    R.id.place_address,
                    R.id.place_distance});
}
 
Example #14
Source File: FileList.java    From styT with Apache License 2.0 6 votes vote down vote up
public void loadList() {
    //getListFromPath(curpath);
    items = new ArrayList<Map<String, Object>>();

    for (int i = 0; i < dirs_name.size(); i++) {
        item = new HashMap<String, Object>();
        item.put("imageItem", R.drawable.ic_save_white_24dp);
        item.put("textItem", dirs_name.get(i));
        items.add(item);
    }
    for (int i = 0; i < files_name.size(); i++) {
        item = new HashMap<String, Object>();
        item.put("imageItem", R.drawable.ic_image_box);
        item.put("textItem", files_name.get(i));
        items.add(item);
    }

    //实例化一个适配器
    SimpleAdapter adapter =
            new SimpleAdapter(this, items, R.layout.filelist_item, new String[]{"imageItem", "textItem", ""}, new int[]{R.id.filelist_item_iv, R.id.filelist_item_tv});
    list.setAdapter(adapter);
    //显示的更加人性化
    setTitle(getShortPath(curpath));
    //getActionBar().setTitle(getShortPath(curpath));
}
 
Example #15
Source File: EmailListActivity.java    From androidmooc-clase1 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	EditText editTextEmail = (EditText)findViewById(R.id.editTextEmail);
	String email = editTextEmail.getText().toString();
	
	if (!email.trim().equals("")) {
		if (Patterns.EMAIL_ADDRESS.matcher(email).matches()) {			
			HashMap<String, String> element = new HashMap<String, String>();
			String date = new SimpleDateFormat("dd/MM/yyyy HH:mm", 
										       Locale.getDefault())
														.format(Calendar.getInstance().getTime());
			element.put(EMAIL, email);
			element.put(DATE_ADDED, "agregado " + date);
			emails.add(element);
			
			final SimpleAdapter adapter = (SimpleAdapter) getListAdapter();
			adapter.notifyDataSetChanged();
		} else {
			Toast.makeText(getApplicationContext(), 
						   getResources().getString(R.string.txt_email_error), 
						   Toast.LENGTH_SHORT).show();
		}
	}
}
 
Example #16
Source File: PadInfoActivity.java    From padland with Apache License 2.0 6 votes vote down vote up
/**
 * Takes the pad data and prepares a list with information,
 * then returns the adapter for the view.
 * @param pad_data
 * @return
 */
private SeparatedListAdapter _doInfoList( Pad pad_data )
{
    List<Map<String,?>> datalist = new LinkedList<>();

    datalist.add( this._doListItem( pad_data.getUrl(), getString(R.string.padinfo_pad_url) ) );
    datalist.add( this._doListItem( pad_data.getCreateDate(this), getString(R.string.padinfo_createdate) ) );
    datalist.add( this._doListItem( pad_data.getLastUsedDate(this), getString(R.string.padinfo_lastuseddate) ) );
    datalist.add( this._doListItem( String.valueOf(pad_data.getAccessCount() ), getString(R.string.padinfo_times_accessed) ) );

    SeparatedListAdapter adapter = new SeparatedListAdapter(this);

    // create our list and custom adapter
    adapter.addSection(getString(R.string.padinfo_pad_info),
            new SimpleAdapter(this, datalist, R.layout.list_complex,
                    new String[] { "title", "caption" },
                    new int[] { R.id.list_complex_title, R.id.list_complex_caption }
            )
    );
    // I leave this here to show an example of how to show another list
    /*adapter.addSection("Options",
            new ArrayAdapter<String>(this, R.layout.list_item, new String[] { "Share", "Delete" })
    );*/

    return adapter;
}
 
Example #17
Source File: Support13Demos.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    String path = intent.getStringExtra("com.example.android.apis.Path");

    if (path == null) {
        path = "";
    }

    setListAdapter(new SimpleAdapter(this, getData(path),
            android.R.layout.simple_list_item_1, new String[] { "title" },
            new int[] { android.R.id.text1 }));
    getListView().setTextFilterEnabled(true);
}
 
Example #18
Source File: PlaceDetailsActivity.java    From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 6 votes vote down vote up
/**
 * Creates ListAdapter populated with offer information.
 *
 * @param offers the list of offers used to populate the adapter.
 * @return an adapter populated with offer information.
 */
private ListAdapter createOfferListAdapter(List<Offer> offers) {
  List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
  for (Offer offer : offers) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("offerIcon", offer.getImageUrl());
    map.put("offerTitle", offer.getTitle());
    map.put("offerDetails", offer.getDescription());
    data.add(map);
  }

  SimpleAdapter adapter = new SimpleAdapter(PlaceDetailsActivity.this, data,
      R.layout.offer_item, new String[] {"offerIcon", "offerTitle", "offerDetails"},
      new int[] {R.id.offer_Image, R.id.offer_name, R.id.offer_description});
  adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
  return adapter;
}
 
Example #19
Source File: SimpleAdapterActivity.java    From SlideAndDragListView with Apache License 2.0 6 votes vote down vote up
public void initUiAndListener() {
    mListView = (SlideAndDragListView) findViewById(R.id.lv_edit);
    mListView.setMenu(mMenu);
    List<Map<String, String>> list = new ArrayList<>(mAppList.size());
    for (ApplicationInfo applicationInfo : mAppList) {
        Map<String, String> map = new HashMap<>();
        map.put("text", applicationInfo.loadLabel(getPackageManager()).toString());
        list.add(map);
    }
    mAdapter = new SimpleAdapter(this, list, R.layout.item_simple_adapter, new String[]{"text"}, new int[]{R.id.txt_simple});
    mListView.setAdapter(mAdapter);
    mListView.setOnDragDropListener(this);
    mListView.setOnItemClickListener(this);
    mListView.setOnSlideListener(this);
    mListView.setOnMenuItemClickListener(this);
    mListView.setOnItemDeleteListener(this);
    mListView.setOnItemLongClickListener(this);
    mListView.setOnItemScrollBackListener(this);
}
 
Example #20
Source File: PlaceDetailsActivity.java    From solutions-mobile-shopping-assistant-android-client with Apache License 2.0 6 votes vote down vote up
/**
 * Creates ListAdapter populated with recommendation information.
 *
 * @param recommendations the list of recommendations used to populate the adapter.
 * @return an adapter populated with recommendation information.
 */
private ListAdapter createRecommendationsListAdapter(List<Recommendation> recommendations) {
  List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
  for (Recommendation recommendation : recommendations) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("productImage", recommendation.getImageUrl());
    map.put("recommendationTitle", recommendation.getTitle());
    map.put("recommendationDetails", recommendation.getDescription());
    data.add(map);
  }

  SimpleAdapter adapter = new SimpleAdapter(PlaceDetailsActivity.this, data,
      R.layout.offer_item,
      new String[] {"productImage", "recommendationTitle", "recommendationDetails"},
      new int[] {R.id.offer_Image, R.id.offer_name, R.id.offer_description});
  adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
  return adapter;
}
 
Example #21
Source File: MainActivity.java    From AndroidInstantVideo with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Loggers.DEBUG = true;
    CrashHandler.init(getApplicationContext());
    getPermission();

    Intent intent = getIntent();
    String path = intent.getStringExtra(INTENT_PATH);

    if (path == null) {
        path = "";
    }

    /*** The "title" is the "key" in "Map" ***/
    setListAdapter(new SimpleAdapter(this, getData(path),
            android.R.layout.simple_list_item_1, new String[] { "title" },
            new int[] { android.R.id.text1 }));

    //If you can get the keyboard, you can type to search the items of the list
    getListView().setTextFilterEnabled(true);

}
 
Example #22
Source File: EmailListActivity.java    From androidmooc-clase1 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	EditText editTextEmail = (EditText)findViewById(R.id.editTextEmail);
	String email = editTextEmail.getText().toString();
	
	if (!email.trim().equals("")) {
		//if (Patterns.EMAIL_ADDRESS.matcher(email).matches()) {			
			HashMap<String, String> element = new HashMap<String, String>();
			String date = new SimpleDateFormat("dd/MM/yyyy HH:mm", 
										       Locale.getDefault())
														.format(Calendar.getInstance().getTime());
			element.put(EMAIL, email);
			element.put(DATE_ADDED, "agregado " + date);
			emails.add(element);
			
			final SimpleAdapter adapter = (SimpleAdapter) getListAdapter();
			adapter.notifyDataSetChanged();
			/*
		} else {
			Toast.makeText(getApplicationContext(), 
						   getResources().getString(R.string.txt_email_error), 
						   Toast.LENGTH_SHORT).show();
		}
		*/
	}
}
 
Example #23
Source File: PlaceDetailsActivity.java    From solutions-mobile-shopping-assistant-backend-java with Apache License 2.0 6 votes vote down vote up
/**
 * Creates ListAdapter populated with recommendation information.
 *
 * @param recommendations the list of recommendations used to populate the adapter.
 * @return an adapter populated with recommendation information.
 */
private ListAdapter createRecommendationsListAdapter(List<Recommendation> recommendations) {
  List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
  for (Recommendation recommendation : recommendations) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("productImage", recommendation.getImageUrl());
    map.put("recommendationTitle", recommendation.getTitle());
    map.put("recommendationDetails", recommendation.getDescription());
    data.add(map);
  }

  SimpleAdapter adapter = new SimpleAdapter(PlaceDetailsActivity.this, data,
      R.layout.offer_item,
      new String[] {"productImage", "recommendationTitle", "recommendationDetails"},
      new int[] {R.id.offer_Image, R.id.offer_name, R.id.offer_description});
  adapter.setViewBinder(new ImageUrlViewBinder(R.id.offer_Image));
  return adapter;
}
 
Example #24
Source File: EmailListActivity.java    From androidmooc-clase1 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_email_list);
	
	Button btnAdd = (Button)findViewById(R.id.btnAdd);
	btnAdd.setOnClickListener(this);
	
	SimpleAdapter adapter = new SimpleAdapter(this, 
											  emails, 
											  android.R.layout.simple_list_item_2, 
											  new String[] {EMAIL, DATE_ADDED}, 
											  new int[] {android.R.id.text1, 
														 android.R.id.text2 });	
	setListAdapter(adapter);
}
 
Example #25
Source File: AppInfoActivity.java    From PretendSharing_Xposed with MIT License 6 votes vote down vote up
private void refreshApps() {
    // (re)load the list of apps in the background
    final PackageManager pm = getPackageManager();
    List<PackageInfo> pkgs = getPackageManager().getInstalledPackages(0);
    List<Map<String,Object>> returnBackList = new ArrayList<Map<String, Object>>();
    for(PackageInfo i:pkgs){
        if((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0 )
            continue; //跳过系统应用
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", String.valueOf(i.applicationInfo.loadLabel(pm)));
        map.put("info", String.valueOf(i.applicationInfo.packageName));
        map.put("img", i.applicationInfo.loadIcon(pm));
        returnBackList.add(map);
    }
    SimpleAdapter adapter = new SimpleAdapter(this,returnBackList,R.layout.vlist,
            new String[]{"title","info","img"},
            new int[]{R.id.title,R.id.info,R.id.img});
    list.setAdapter(adapter);
}
 
Example #26
Source File: DemoListActivity.java    From Tangram-Android with MIT License 6 votes vote down vote up
@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> parse = new HashMap<String, String>();
    parse.put("name", "基本Tangram");
    parse.put("class", TangramActivity.class.getName());
    list.add(parse);
    HashMap<String, String> api = new HashMap<String, String>();
    api.put("name", "响应式Tangram");
    api.put("class", RxTangramActivity.class.getName());
    list.add(api);
    HashMap<String, String> bizItems = new HashMap<String, String>();
    bizItems.put("name", "自定义数据解析");
    bizItems.put("class", TangramDataParserActivity.class.getName());
    list.add(bizItems);
    HashMap<String, String> tangram3Items = new HashMap<String, String>();
    tangram3Items.put("name", "Tangram 3.0 (beta)");
    tangram3Items.put("class", Tangram3Activity.class.getName());
    list.add(tangram3Items);
    ListAdapter listAdapter = new SimpleAdapter(this, list, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1});
    setListAdapter(listAdapter);
}
 
Example #27
Source File: Support4Demos.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    Intent intent = getIntent();
    String path = intent.getStringExtra("com.example.android.apis.Path");
    
    if (path == null) {
        path = "";
    }

    setListAdapter(new SimpleAdapter(this, getData(path),
            android.R.layout.simple_list_item_1, new String[] { "title" },
            new int[] { android.R.id.text1 }));
    getListView().setTextFilterEnabled(true);
}
 
Example #28
Source File: QueryRMBQuotationByBank.java    From stynico with MIT License 6 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_exchange_rmb_quotation);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
       btnICBC = forceCast(findViewById(R.id.btnICBC));
       btnCMB = forceCast(findViewById(R.id.btnCMB));
       btnCCB = forceCast(findViewById(R.id.btnCCB));
       btnBOC = forceCast(findViewById(R.id.btnBOC));
       btnBCM = forceCast(findViewById(R.id.btnBCM));
       btnABC = forceCast(findViewById(R.id.btnABC));
       tvTittle = forceCast(findViewById(R.id.tvTittle));
       lvResult = forceCast(findViewById(R.id.lvResult));

       btnICBC.setOnClickListener(this);
       btnCMB.setOnClickListener(this);
       btnCCB.setOnClickListener(this);
       btnBOC.setOnClickListener(this);
       btnBCM.setOnClickListener(this);
       btnABC.setOnClickListener(this);

       //init data
       adapter = new SimpleAdapter(this, dataList, R.layout.view_exchange_rmb_quotation_item,
               new String[]{"bankName", "bank", "currencyName", "currencyCode", "fBuyPri", "mBuyPri", "fSellPri", "mSellPri", "bankConversionPri", "date", "time"},
               new int[]{R.id.tvBankName, R.id.tvBankCode, R.id.tvCurrencyName, R.id.tvCurrencyCode, R.id.tvFBuyPri, R.id.tvMBuyPri, R.id.tvFSellPri, R.id.tvMSellPri, R.id.tvBankConversionPri, R.id.tvDate, R.id.tvTime});
       lvResult.setAdapter(adapter);
   }
 
Example #29
Source File: FileListView.java    From qplayer-sdk with MIT License 6 votes vote down vote up
private void updateURLList (String strFile) {
    m_strListPath = m_strListPath + "/url";
    ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    HashMap<String, Object> map;

    try {
        FileInputStream fis = new FileInputStream (strFile);
        BufferedReader br = new BufferedReader(new InputStreamReader(fis));
        String line = null;
        while((line = br.readLine())!=null)
        {
            map = new HashMap<String, Object>();
            map.put("name", line);
            map.put("path", line);
            map.put("img", R.drawable.item_video);
            map.put("dir", "2");
            list.add(map);
        }
    }catch (Exception e) {
        e.printStackTrace();
    }

    SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.list_item,
            new String[]{"name","img"}, new int[]{R.id.name, R.id.img});
    m_lstFiles.setAdapter(adapter);
}
 
Example #30
Source File: CountryPickerFragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void applyFilter(@NonNull CharSequence text) {
  SimpleAdapter listAdapter = (SimpleAdapter) getListAdapter();

  if (listAdapter != null) {
    listAdapter.getFilter().filter(text);
  }
}