List of usage examples for android.widget SimpleAdapter SimpleAdapter
public SimpleAdapter(Context context, List<? extends Map<String, ?>> data, @LayoutRes int resource, String[] from, @IdRes int[] to)
From source file:com.abeo.tia.noordin.ProcessCasePurchaser.java
public void dropdownKIV() throws JSONException { RequestParams params = null;/*from w w w . java 2s.co m*/ params = new RequestParams(); JSONObject jsonObject = new JSONObject(); jsonObject.put("TableName", "OCRD"); jsonObject.put("FieldName", "KIVSTATUS"); params.put("sJsonInput", jsonObject.toString()); RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() { @Override public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) { // TODO Auto-generated method stub System.out.println(arg3); System.out.println("Failed"); } @Override protected String parseResponse(String s, boolean b) throws Throwable { return null; } @Override public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) { // TODO Auto-generated method stub System.out.println("Title Dropdown Success Details "); System.out.println(arg2); try { arrayResponse = new JSONArray(arg2); // Create new list jsonArraylist = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < arrayResponse.length(); i++) { jsonResponse = arrayResponse.getJSONObject(i); id = jsonResponse.getString("Id").toString(); name = jsonResponse.getString("Name").toString(); // SEND JSON DATA INTO SPINNER TITLE LIST HashMap<String, String> proList = new HashMap<String, String>(); // Send JSON Data to list activity System.out.println("SEND JSON LIST"); proList.put("Id_T", id); System.out.println(name); proList.put("Name_T", name); System.out.println(name); System.out.println(" END SEND JSON PROPERTY LIST"); jsonArraylist.add(proList); System.out.println("JSON PROPERTY LIST"); System.out.println(jsonArraylist); } // Spinner set Array Data in Drop down sAdapPROJ = new SimpleAdapter(ProcessCasePurchaser.this, jsonArraylist, R.layout.spinner_item, new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name }); spinner_kiv.setAdapter(sAdapPROJ); for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Skiv)) { spinner_kiv.setSelection(j); break; } } } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:im.afterclass.android.fragment.ChatHistoryFragment.java
private void setListView(View v) { // LayoutInflater inflater = LayoutInflater.from(getActivity()); // View view = inflater.inflate(R.layout.half_popupwindow, null); String[] themes = new String[] { "?", "??", "" }; List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>(); for (int i = 0; i < themes.length; i++) { Map<String, Object> listItem = new HashMap<String, Object>(); listItem.put("theme", themes[i]); listItems.add(listItem);//from w ww. j a v a 2 s .c o m } SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), listItems, R.layout.theme_simple_item, new String[] { "theme" }, new int[] { R.id.theme }); ListView themelist = (ListView) inflater.inflate(R.layout.half_popupwindow, null) .findViewById(R.id.themeListView); themelist.setAdapter(simpleAdapter); themelist.setOnItemClickListener(new ItemClickListener()); }
From source file:im.afterclass.android.fragment.ChatHistoryFragment.java
private void showRightPopupWindow(View v) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View parent = getActivity().findViewById(R.id.main_button); View view = inflater.inflate(R.layout.half_popupwindow, null); String[] themes = new String[] { "?", "??", "" }; List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>(); for (int i = 0; i < themes.length; i++) { Map<String, Object> listItem = new HashMap<String, Object>(); listItem.put("theme", themes[i]); listItems.add(listItem);/*from ww w .j a va 2s . c o m*/ } SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), listItems, R.layout.theme_simple_item, new String[] { "theme" }, new int[] { R.id.theme }); ListView themelist = (ListView) view.findViewById(R.id.themeListView); themelist.setAdapter(simpleAdapter); themelist.setOnItemClickListener(new ItemClickListener()); mPopupWindow = new PopupWindow(view); view.startAnimation(animSlideRightin); DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); int screenHeight = dm.heightPixels; int[] location = new int[2]; parent.getLocationInWindow(location); Rect frame = new Rect(); getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; int width = frame.width(); mPopupWindow.setHeight(location[1] - getActivity().getActionBar().getHeight() - statusBarHeight); mPopupWindow.setWidth(width / 2); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.showAtLocation(getActivity().findViewById(R.id.main_bottom), Gravity.BOTTOM | Gravity.RIGHT, 0, screenHeight - location[1]); }
From source file:system.info.reader.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); resolutions = Properties.resolution(dm); Properties.resolution = resolutions[0] + "*" + resolutions[1]; int tabHeight = 30, tabWidth = 80; if (dm.widthPixels >= 480) { tabHeight = 40;/*from www . j a v a2 s . com*/ tabWidth = 120; } tabHost = getTabHost(); LayoutInflater.from(this).inflate(R.layout.main, tabHost.getTabContentView(), true); tabHost.addTab( tabHost.newTabSpec("tab1").setIndicator(getString(R.string.brief)).setContent(R.id.PropertyList)); tabHost.addTab( tabHost.newTabSpec("tab2").setIndicator(getString(R.string.online)).setContent(R.id.ViewServer)); tabHost.addTab( tabHost.newTabSpec("tab3").setIndicator(getString(R.string.apps)).setContent(R.id.sViewApps)); tabHost.addTab( tabHost.newTabSpec("tab4").setIndicator(getString(R.string.process)).setContent(R.id.sViewProcess)); tabHost.addTab(tabHost.newTabSpec("tab5").setIndicator("Services").setContent(R.id.sViewCpu)); tabHost.addTab(tabHost.newTabSpec("tab6").setIndicator("Tasks").setContent(R.id.sViewMem)); //tabHost.addTab(tabHost.newTabSpec("tab7") // .setIndicator("Vending") // .setContent(R.id.sViewDisk)); AppsText = (TextView) findViewById(R.id.TextViewApps); ProcessText = (TextView) findViewById(R.id.TextViewProcess); ServiceText = (TextView) findViewById(R.id.TextViewCpu); TaskText = (TextView) findViewById(R.id.TextViewMem); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(tabWidth, tabHeight); for (int i = 0; i < tabHost.getTabWidget().getChildCount(); i++) tabHost.getTabWidget().getChildAt(i).setLayoutParams(lp); properList = (ListView) findViewById(R.id.PropertyList); Properties.properListItem = new ArrayList<HashMap<String, Object>>(); properListItemAdapter = new SimpleAdapter(this, Properties.properListItem, R.layout.property_list, new String[] { "ItemTitle", "ItemText" }, new int[] { R.id.ItemTitle, R.id.ItemText }); properList.setAdapter(properListItemAdapter); properList.setOnItemClickListener(mpropertyCL); //will support app list later //appList = (ListView)findViewById(R.id.AppList); //Properties.appListItem = new ArrayList<HashMap<String, Object>>(); //SimpleAdapter appListItemAdapter = new SimpleAdapter(this, Properties.appListItem, // R.layout.app_list, // new String[] {"ItemTitle", "ItemText"}, // new int[] {R.id.ItemTitle, R.id.ItemText} // ); //appList.setAdapter(appListItemAdapter); serverWeb = (WebView) findViewById(R.id.ViewServer); WebSettings webSettings = serverWeb.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setUserAgentString("sys.info.trial" + versionCode); webSettings.setTextSize(WebSettings.TextSize.SMALLER); serverWeb.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return false;//this will not launch browser when redirect. } public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); PackageManager pm = getPackageManager(); try { PackageInfo pi = pm.getPackageInfo("sys.info.trial", 0); version = "v" + pi.versionName; versionCode = pi.versionCode; List<PackageInfo> apps = getPackageManager().getInstalledPackages(0); nApk = Integer.toString(apps.size()); apklist = ""; for (PackageInfo app : apps) { apklist += app.packageName + "\t(" + app.versionName + ")\n"; } } catch (NameNotFoundException e) { e.printStackTrace(); } showDialog(0); initPropList(); //refresh(); PageTask task = new PageTask(); task.execute(""); }
From source file:com.owncloud.android.ui.activity.Uploader.java
private void populateDirectoryList() { setContentView(R.layout.uploader_layout); ListView mListView = (ListView) findViewById(android.R.id.list); String current_dir = mParents.peek(); if (current_dir.equals("")) { getSupportActionBar().setTitle(getString(R.string.default_display_name_for_root_folder)); } else {//from w w w . ja v a 2 s . co m getSupportActionBar().setTitle(current_dir); } boolean notRoot = (mParents.size() > 1); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(notRoot); actionBar.setHomeButtonEnabled(notRoot); String full_path = generatePath(mParents); Log_OC.d(TAG, "Populating view with content of : " + full_path); mFile = getStorageManager().getFileByPath(full_path); if (mFile != null) { // TODO Enable when "On Device" is recovered ? Vector<OCFile> files = getStorageManager().getFolderContent(mFile/*, false*/); List<HashMap<String, Object>> data = new LinkedList<HashMap<String, Object>>(); for (OCFile f : files) { HashMap<String, Object> h = new HashMap<String, Object>(); if (f.isFolder()) { h.put("dirname", f.getFileName()); data.add(h); } } SimpleAdapter sa = new SimpleAdapter(this, data, R.layout.uploader_list_item_layout, new String[] { "dirname" }, new int[] { R.id.filename }); mListView.setAdapter(sa); Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder); btnChooseFolder.setOnClickListener(this); Button btnNewFolder = (Button) findViewById(R.id.uploader_cancel); btnNewFolder.setOnClickListener(this); mListView.setOnItemClickListener(this); } }
From source file:com.dosse.bwentrain.androidPlayer.MainActivity.java
private void populatePresetList() { final ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); ArrayList<String> fileList = new ArrayList<String>(); String[] downloads = fileList(); //get all files downloaded from the preset sharing platform for (String s : downloads) //add all downloaded presets if (s.toLowerCase().endsWith(".sin")) { fileList.add(s);// w ww .ja va 2s. co m } //generate items for ListView //add link to preset sharing platform HashMap<String, String> siteLink = new HashMap<String, String>(); siteLink.put("title", getString(R.string.download_presets)); siteLink.put("author", getString(R.string.theyre_free)); siteLink.put("description", ""); siteLink.put("path", getString(R.string.presets_url)); list.add(siteLink); for (String f : fileList) { Preset p = loadPreset(f); if (p == null) continue; HashMap<String, String> item = new HashMap<String, String>(); item.put("title", p.getTitle()); item.put("author", p.getAuthor()); item.put("description", p.getDescription()); item.put("length", "" + Utils.toHMS(p.getLength())); item.put("loop", "" + (p.loops() ? Utils.toHMS(p.getLoop()) : "")); item.put("path", f); list.add(item); } //insert all into ListView ListView files = (ListView) findViewById(R.id.listView1); files.setAdapter(new SimpleAdapter(this, list, android.R.layout.simple_list_item_2, new String[] { "title", "author" }, new int[] { android.R.id.text1, android.R.id.text2 })); //tap on item files.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { HashMap<String, String> item = list.get(position); if (item.get("path").startsWith("http://")) { //link Intent i = new Intent(MainActivity.this, BrowserActivity.class); i.putExtra("path", item.get("path")); startActivity(i); } else { //preset Intent i = new Intent(MainActivity.this, DetailsActivity.class); i.putExtra("title", item.get("title")); i.putExtra("author", item.get("author")); i.putExtra("description", item.get("description")); i.putExtra("length", item.get("length")); i.putExtra("loop", item.get("loop")); i.putExtra("path", item.get("path")); startActivity(i); } } }); //long tap on item files.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { HashMap<String, String> item = list.get(position); final String path = item.get("path"); if (path.startsWith("http://")) return true; //can't delete links //delete preset //ask for confirm AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); DialogInterface.OnClickListener l = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_POSITIVE) { //delete confirmed if (new File(path).exists()) { //delete file on sdcard new File(path).delete(); } else {//delete from app data deleteFile(path); } populatePresetList(); //repopulate preset list } } }; builder.setMessage(getString(R.string.delete_confirm) + " \"" + item.get("title") + "\"?") .setPositiveButton(getString(R.string.yes), l).setNegativeButton(getString(R.string.no), l) .show(); return true; } }); }
From source file:com.abeo.tia.noordin.ProcessCaseVendor.java
public void dropdownstatus() throws JSONException { RequestParams params = null;/* w w w. j a v a2s .co m*/ params = new RequestParams(); JSONObject jsonObject = new JSONObject(); jsonObject.put("TableName", "OCRD"); jsonObject.put("FieldName", "CASESTATUS"); params.put("sJsonInput", jsonObject.toString()); RestService.post(GET_SPINNER_VALUES, params, new BaseJsonHttpResponseHandler<String>() { @Override public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) { // TODO Auto-generated method stub System.out.println(arg3); System.out.println("Failed"); } @Override protected String parseResponse(String s, boolean b) throws Throwable { return null; } @Override public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) { // TODO Auto-generated method stub System.out.println("Title Dropdown Success Details "); System.out.println(arg2); try { arrayResponse = new JSONArray(arg2); // Create new list jsonArraylist = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < arrayResponse.length(); i++) { jsonResponse = arrayResponse.getJSONObject(i); id = jsonResponse.getString("Id").toString(); name = jsonResponse.getString("Name").toString(); // SEND JSON DATA INTO SPINNER TITLE LIST HashMap<String, String> proList = new HashMap<String, String>(); // Send JSON Data to list activity System.out.println("SEND JSON LIST"); proList.put("Id_T", id); System.out.println(name); proList.put("Name_T", name); System.out.println(name); System.out.println(" END SEND JSON PROPERTY LIST"); jsonArraylist.add(proList); System.out.println("JSON PROPERTY LIST"); System.out.println(jsonArraylist); } // Spinner set Array Data in Drop down sAdapPROJ = new SimpleAdapter(ProcessCaseVendor.this, jsonArraylist, R.layout.spinner_item, new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name }); spinner_case_status.setAdapter(sAdapPROJ); for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Scase_status)) { spinner_case_status.setSelection(j); break; } } } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:smart.services.adapter.ManageCarsAdapter.java
public void showBrandDialog() { if (dataBaseHandler.getBrandsCount() == 0) { if (isConnectingToInternet()) { new BrandAsyncTask().execute(); } else {/*w w w .ja v a 2s . co m*/ Toast.makeText(context, "Check your internet connection", Toast.LENGTH_LONG).show(); } } else { dialog.setContentView(R.layout.add_car_dialog); dialog.setCancelable(true); dialog.setTitle("Choose a Brand"); Booking.changeWidthHeight(context, dialog); // dialog.setP lv = (ListView) dialog.findViewById(R.id.addLV); List<Brand> brandList = dataBaseHandler.getAllBrands(); carsBrandList.clear(); for (int i = 0; i < brandList.size(); i++) { HashMap<String, String> brand = new HashMap<String, String>(); brand.put("typeId", brandList.get(i).getTypeId()); brand.put("typeNameAr", brandList.get(i).getTypeNameAr()); brand.put("typeNameEn", brandList.get(i).getTypeNameEn()); brand.put("carModels", brandList.get(i).getCarModels()); carsBrandList.add(brand); } ListAdapter adapter = new SimpleAdapter(context, carsBrandList, R.layout.single_brand_item, new String[] { "typeId", "typeNameEn" }, new int[] { R.id.typeId, R.id.typeNameEn }); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // Toast.makeText(context, "", Toast.LENGTH_SHORT).show(); finalTypeId = carsBrandList.get(position).get("typeId"); String s = ((TextView) view.findViewById(R.id.typeNameEn)).getText().toString(); brandTV.setText(s); String sId = ((TextView) view.findViewById(R.id.typeId)).getText().toString(); brandIdTV.setText(sId); dialog.dismiss(); } }); dialog.show(); } }
From source file:com.abeo.tia.noordin.ProcessCasePurchaser.java
public void dropdowntype1() throws JSONException { RequestParams params = null;//from w w w .ja v a 2 s. c o m params = new RequestParams(); JSONObject jsonObject = new JSONObject(); /* * jsonObject.put("TableName", "OCRD"); jsonObject.put("FieldName", * "KIVSTATUS"); */ params.put("sJsonInput", jsonObject.toString()); RestService.post(GET_TYPE_SPINNER, params, new BaseJsonHttpResponseHandler<String>() { @Override public void onFailure(int arg0, Header[] arg1, Throwable arg2, String arg3, String arg4) { // TODO Auto-generated method stub System.out.println(arg3); System.out.println("Failed"); } @Override protected String parseResponse(String s, boolean b) throws Throwable { return null; } @Override public void onSuccess(int arg0, Header[] arg1, String arg2, String arg3) { // TODO Auto-generated method stub System.out.println("Title Dropdown Success Details "); System.out.println(arg2); try { arrayResponse = new JSONArray(arg2); // Create new list jsonArraylist = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < arrayResponse.length(); i++) { jsonResponse = arrayResponse.getJSONObject(i); id = jsonResponse.getString("Id").toString(); name = jsonResponse.getString("Name").toString(); // SEND JSON DATA INTO SPINNER TITLE LIST HashMap<String, String> proList = new HashMap<String, String>(); // Send JSON Data to list activity System.out.println("SEND JSON LIST"); proList.put("Id_T", id); System.out.println(name); proList.put("Name_T", name); System.out.println(name); System.out.println(" END SEND JSON PROPERTY LIST"); jsonArraylist.add(proList); System.out.println("JSON PROPERTY LIST"); System.out.println(jsonArraylist); } // Spinner set Array Data in Drop down sAdapPROJ = new SimpleAdapter(ProcessCasePurchaser.this, jsonArraylist, R.layout.spinner_item, new String[] { "Id_T", "Name_T" }, new int[] { R.id.Id, R.id.Name }); // All adapters has been set here spinner_type1.setAdapter(sAdapPROJ); spinner_type2.setAdapter(sAdapPROJ); spinner_type3.setAdapter(sAdapPROJ); spinner_type4.setAdapter(sAdapPROJ); System.out.println("Thomas Test Type"); System.out.println(Stype1); for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Stype1)) { spinner_type1.setSelection(j); break; } } for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Stype2)) { spinner_type2.setSelection(j); break; } } for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Stype3)) { spinner_type1.setSelection(j); break; } } for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Stype3)) { spinner_type1.setSelection(j); break; } } for (int j = 0; j < jsonArraylist.size(); j++) { if (jsonArraylist.get(j).get("Id_T").equals(Stype4)) { spinner_type4.setSelection(j); break; } } } catch (JSONException e) { e.printStackTrace(); } } }); }
From source file:im.afterclass.android.fragment.ChatHistoryFragment.java
private void showLeftPopupWindow(View v) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View parent = getActivity().findViewById(R.id.main_button); View view = inflater.inflate(R.layout.half_popupwindow, null); String[] themes = new String[] { "?", "??", "" }; List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>(); for (int i = 0; i < themes.length; i++) { Map<String, Object> listItem = new HashMap<String, Object>(); listItem.put("theme", themes[i]); listItems.add(listItem);// www.j av a 2s. c o m } SimpleAdapter simpleAdapter = new SimpleAdapter(getActivity(), listItems, R.layout.theme_simple_item, new String[] { "theme" }, new int[] { R.id.theme }); ListView themelist = (ListView) view.findViewById(R.id.themeListView); themelist.setAdapter(simpleAdapter); themelist.setOnItemClickListener(new ItemClickListener()); mPopupWindow = new PopupWindow(view); view.startAnimation(animSlideLeftin); DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); int screenHeight = dm.heightPixels; int[] location = new int[2]; parent.getLocationInWindow(location); Rect frame = new Rect(); getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; int width = frame.width(); mPopupWindow.setHeight(location[1] - getActivity().getActionBar().getHeight() - statusBarHeight); mPopupWindow.setWidth(width / 2); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setBackgroundDrawable(new BitmapDrawable()); mPopupWindow.showAtLocation(getActivity().findViewById(R.id.main_bottom), Gravity.BOTTOM | Gravity.LEFT, 0, screenHeight - location[1]); }