List of usage examples for android.widget ArrayAdapter ArrayAdapter
public ArrayAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<T> objects)
From source file:com.krayzk9s.imgurholo.ui.CommentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.account_layout, container, false); LinearLayout headerLayout = (LinearLayout) view.findViewById(R.id.header); headerLayout.setVisibility(View.GONE); errorText = (TextView) view.findViewById(R.id.error); mDrawerList = (ListView) view.findViewById(R.id.account_list); ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); SharedPreferences settings = activity.getApiCall().settings; if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT)) commentsAdapter = new MessageAdapter(activity, R.layout.comment_layout); else/* w ww .java 2 s. c o m*/ commentsAdapter = new MessageAdapter(activity, R.layout.comment_layout_dark); String[] mMenuList = getResources().getStringArray(R.array.emptyList); ArrayAdapter<String> tempAdapter; if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT)) tempAdapter = new ArrayAdapter<String>(activity, R.layout.comment_layout, mMenuList); else tempAdapter = new ArrayAdapter<String>(activity, R.layout.comment_layout_dark, mMenuList); mDrawerList.setAdapter(tempAdapter); if (savedInstanceState == null) { getComments(); } else { commentDataArray = savedInstanceState.getParcelableArrayList("content"); commentsAdapter.addAll(commentDataArray); mDrawerList.setAdapter(commentsAdapter); commentsAdapter.notifyDataSetChanged(); } return view; }
From source file:com.example.pyrkesa.frag.User_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setRetainInstance(true);// ww w . j a va 2s . co m rootView = inflater.inflate(R.layout.user_fragment, container, false); userList = (ListView) rootView.findViewById(R.id.lt_user); // custom dialog final Dialog dialog = new Dialog(rootView.getContext()); d = dialog; userIcons = getResources().obtainTypedArray(R.array.userIcons);// load icons from userIcons1 = getResources().obtainTypedArray(R.array.userIcons1); userItems = new ArrayList<UserItem>(); adapter = new UserAdapter(getActivity(), userItems, getActivity()); userList.setAdapter(adapter); ImageButton addButton = (ImageButton) rootView.findViewById(R.id.add); addButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ModelFactory model = (ModelFactory) ModelFactory.getContext(); if (model.user.type == 1) { dialog.setContentView(R.layout.adduser_dialog); dialog.setTitle("Ajouter un utilisateur "); dialogTypes = getResources().getStringArray(R.array.user_type_dialog); // load Button dialogButtonOk = (Button) dialog.findViewById(R.id.button_ok); Button dialogButtonCancel = (Button) dialog.findViewById(R.id.button_cancel); final EditText Newlogin = (EditText) dialog.findViewById(R.id.dialogLogin); final EditText NewPW = (EditText) dialog.findViewById(R.id.dialogPW); final Spinner NewType = (Spinner) dialog.findViewById(R.id.dialogType); ArrayList<String> types = new ArrayList<String>(); for (String t : dialogTypes) { types.add(t); } NewType.setAdapter(new ArrayAdapter<String>(rootView.getContext(), android.R.layout.simple_spinner_dropdown_item, types)); dialogButtonCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialogButtonOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<String> temp = new ArrayList<String>(); String login = Newlogin.getText().toString(); String password = NewPW.getText().toString(); String type = NewType.getSelectedItem().toString(); if (login.equalsIgnoreCase("") && password.equalsIgnoreCase("") && type != null) { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Veuillez remplir toutes les informations.").show(); } else { temp.add(login); temp.add(password); if (type.equalsIgnoreCase("admin")) { temp.add("1"); } else if (type.equalsIgnoreCase("utilisateur")) { temp.add("0"); } else { temp.add("0"); } } new addUser().execute(temp); } }); dialog.show(); } else { new AlertDialog.Builder(v.getContext()).setTitle("Attention") .setMessage("Opration interdite : Droits d'administration requis.").show(); } } }); // adding user items new LoadAllUser().execute(); return rootView; }
From source file:fyp.project.S_File.S_Activities.java
public void doWay(String server_output) { /* tvOutput.setText(Environment.getExternalStorageDirectory() + "/DCIM/Camera/a.mp4");*/ JSONArray array = null;/*w w w .j a va 2 s.c om*/ List<String> list_output = new ArrayList<String>(); String output = server_output; if (!output.equals("[]")) { Logger.getLogger(S_Login.class.getName()).info("true..............."); try { array = new JSONArray(server_output); } catch (JSONException ex) { Logger.getLogger(S_Login.class.getName()).log(Level.SEVERE, null, ex); } for (int n = 0; n < array.length(); n++) { String temp = ""; for (int m = 0; m < 3; m++) { try { output += " " + array.getJSONArray(n).get(m).toString() + "\n "; temp += " " + array.getJSONArray(n).get(m).toString() + "\n "; } catch (JSONException ex) { Logger.getLogger(S_Login.class.getName()).log(Level.SEVERE, null, ex); } } list_output.add(temp); output += "\n"; } aryAdapter_list = new ArrayAdapter(activity, android.R.layout.simple_list_item_1, list_output); gv.setAdapter(aryAdapter_list); Logger.getLogger(S_Login.class.getName()).info(output); } else { EditText edit_username = (EditText) activity.findViewById(R.id.edit_username); EditText edit_password = (EditText) activity.findViewById(R.id.edit_password); if (output.equals("[]")) { tvOutput.setText("Please Login Again" + server_output); edit_username.setText(""); edit_password.setText(""); } else { tvOutput.setText("Page Not Found 404" + server_output); } /*AlertDialog.Builder MyAlertDialog = new AlertDialog.Builder(activity); MyAlertDialog.setTitle("Login Fail"); MyAlertDialog.setMessage("Please Login Again"); MyAlertDialog.show(); */ } mProgressDialog.dismiss(); }
From source file:anomalyDetector.activities.MainFeaturesActivity.java
@Override protected void onStart() { super.onStart(); selectedFeatures = new ArrayList<String>(); /*// w w w. ja v a 2s. com * Check if the service is running */ ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> rs = am.getRunningServices(100); for (ActivityManager.RunningServiceInfo rsi : rs) { String serviceClassName = rsi.service.getClassName(); if (serviceClassName.equals("anomalyDetector.services.ColectFeaturesService")) { isServiceRunning = true; drawerItemClickListener.setServiceRunning(true); break; } } // Enable or disable the buttons based on service status(running or not running) if (isServiceRunning) { startServiceButton.setEnabled(false); stopServiceButton.setEnabled(true); } else { startServiceButton.setEnabled(true); stopServiceButton.setEnabled(false); } /* * List of features that can be collected */ AssetManager assetManager = getAssets(); BufferedReader reader; /* * Read the features from assets and add them to the arraylist */ try { reader = new BufferedReader(new InputStreamReader(assetManager.open("features.txt"))); String line; while ((line = reader.readLine()) != null) { // Skip comments if (line.startsWith("#")) { continue; } selectedFeatures.add(line); } reader.close(); } catch (IOException e) { Log.d("MainFeaturesActivity", "Error reading assets file"); } // Create an adapter that holds the selected features // and pass it to the list view listViewAdapter = new ArrayAdapter<String>(this, R.layout.row, selectedFeatures); listView.setAdapter(listViewAdapter); }
From source file:com.zira.registration.BackgroundCheckActivity.java
private void setApapterForCity() { ArrayAdapter<City> dataAdapter = new ArrayAdapter<City>(this, R.layout.spinner_list, arraylist_city); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); citySpinner.setAdapter(dataAdapter); citySpinner.setSelection(gettingCityPosition); }
From source file:org.ueu.uninet.it.IragarkiaBidali.java
/** * Prestatu iragarki berria bidaltzeko formularioa *//*from ww w . ja v a 2 s . c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.iragarkia_bidali); this.ekintza = this; this.izena = (EditText) findViewById(R.id.editTextIzena); this.izenburua = (EditText) findViewById(R.id.editTextIzenburua); this.eposta = (EditText) findViewById(R.id.editTextEposta); this.telefonoa = (EditText) findViewById(R.id.editTextTelefonoa); this.mezua = (EditText) findViewById(R.id.editTextDeskribapena); this.ohar_legala = (CheckBox) findViewById(R.id.checkBoxlegalAdviceBidali); this.errobota = (EditText) findViewById(R.id.editTextErrobota); this.atala = (Spinner) findViewById(R.id.spinnerAtala); imgView = (ImageView) findViewById(R.id.ImageView); upload = (Button) findViewById(R.id.Upload); bidali = (Button) findViewById(R.id.iragarkiaBidali); // Iragarkiak irudirik badu galeriatik kargatu upload.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getApplicationContext(), "Aukeratu irudi bat.", Toast.LENGTH_SHORT).show(); try { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Irudia aukeratu"), PICK_IMAGE); } catch (Exception e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }); // Formularioa bidali bidali.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (balidatu()) { dialog = ProgressDialog.show(IragarkiaBidali.this, "Fitxategia igotzen eta mezua bidaltzen", "Itxaron mesedez...", true); //Formularioa eta irudia bidali new ImageUploadTask().execute(); } } }); ArrayAdapter<String> iragarki_motak = new ArrayAdapter<String>(this, R.layout.spinner_view, getResources().getStringArray(R.array.iragarki_kategoriak)); iragarki_motak.setDropDownViewResource(R.layout.spinner_view_dropdown); this.atala.setAdapter(iragarki_motak); // Sareko monitora prestatu NetworkConnectivity.sharedNetworkConnectivity().configure(this); NetworkConnectivity.sharedNetworkConnectivity().addNetworkMonitorListener(this); NetworkConnectivity.sharedNetworkConnectivity().startNetworkMonitor(); }
From source file:system.info.reader.java
public void showMyDialog(String[] valuse) { ArrayAdapter itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, valuse); View myView = getLayoutInflater().inflate(R.layout.popup, (ViewGroup) findViewById(R.id.popup_root)); ListView itemView = (ListView) myView.findViewById(R.id.PropertyList); itemView.setAdapter(itemAdapter);//from ww w. j a v a2 s . co m itemView.setOnItemClickListener(msubitemCL); AlertDialog altDialog = new AlertDialog.Builder(this).setView(myView).create(); altDialog.setOnKeyListener(null); m_altDialog = altDialog; altDialog.show(); }
From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java
@Override public void onGetInputtips(List<Tip> tipList, int rCode) { if (rCode == 1000) { List<String> listString = new ArrayList<String>(); for (int i = 0; i < tipList.size(); i++) { listString.add(tipList.get(i).getName()); }// w w w . jav a2s . co m ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this, R.layout.route_inputs, listString); mResultText.setAdapter(aAdapter); aAdapter.notifyDataSetChanged(); } else { showToast(rCode + ""); } }
From source file:com.echlabsw.android.drawertab.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "onCreate"); setContentView(R.layout.activity_main); createStubTab();//from w w w .jav a2 s. c o m mActionBar = getActionBar(); mHorizontalTabScrollView = (HorizontalScrollView) findViewById(R.id.hscroll_tab_host); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerListView = (ListView) findViewById(R.id.left_drawer); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mActionBar.setHomeButtonEnabled(true); mActionBar.setDisplayHomeAsUpEnabled(true); mDrawerToggle = createDrawerToggleListener(); mDrawerLayout.setDrawerListener(mDrawerToggle); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); for (String tag : mTabMap.keySet()) { Tab tab = mTabMap.get(tag); TabHost.TabSpec spec = mTabHost.newTabSpec(tag); spec.setContent(this); spec.setIndicator(tab.title); mTabHost.addTab(spec); } mViewPager = (ViewPager) findViewById(R.id.pager); mAdapter = new TabsPagerAdapter(getSupportFragmentManager(), mTabMap.size()); mViewPager.setAdapter(mAdapter); mTabHost.setOnTabChangedListener(this); mViewPager.setOnPageChangeListener(this); if (!TAB_SCROLL_ENABLED) { mHorizontalTabScrollView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_UP: v.performClick(); break; } return true; } }); } mArrayNavigationDrawerAdapter = new ArrayAdapter<Tab>(this, android.R.layout.simple_list_item_1, mTabMap.values().toArray(new Tab[0])); mDrawerListView.setAdapter(mArrayNavigationDrawerAdapter); mDrawerListView.setOnItemClickListener(this); /* Create AsyncTaskLoader */ getSupportLoaderManager().initLoader(0, null, this); }