List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:org.rapidandroid.activity.FormReviewer.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setTitle(getString(R.string.app_name) + " :: Review Form"); setContentView(R.layout.form_edit);/*www. jav a 2 s . co m*/ Bundle extras = getIntent().getExtras(); if (extras != null) { if (!extras.containsKey(CallParams.REVIEW_FORM)) { throw new IllegalArgumentException("Error, activity was called without a Form ID to review."); } int formID = extras.getInt(CallParams.REVIEW_FORM); mForm = ModelTranslator.getFormById(formID); TextView txv_formname = (TextView) findViewById(R.id.txv_formname); TextView txv_prefix = (TextView) findViewById(R.id.txv_formprefix); TextView txv_description = (TextView) findViewById(R.id.txv_description); TextView txv_parsertype = (TextView) findViewById(R.id.txv_parsertype); ListView lsv_fields = (ListView) findViewById(R.id.lsv_fields); txv_formname.setText(mForm.getFormName()); txv_prefix.setText(mForm.getPrefix()); txv_description.setText(mForm.getDescription()); txv_parsertype.setText(mForm.getParserType().toString()); // int len = mForm.getFields().length; // lsv_fields.setAdapter(new ArrayAdapter<String>(this, // android.R.layout.simple_list_item_1, fields)); ArrayList<Field> fields = new ArrayList<Field>(); Field[] f = mForm.getFields(); for (Field ff : f) { fields.add(ff); } lsv_fields.setAdapter(new FieldViewAdapter(this, fields)); } }
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * /* w ww . j a v a2 s.com*/ * @param arrayId * @param editViewId */ private void choose(final int arrayId, final int editViewId) { View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1).create(); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); final ListView listView = new ListView(view1.getContext()); listView.setAdapter(new ArrayAdapter<String>(view1.getContext(), android.R.layout.simple_list_item_1, view1.getResources().getStringArray(arrayId))); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dialog.dismiss(); String temp = (String) listView.getItemAtPosition(i); setEditViewText(rootView, editViewId, temp); } }); contentArea.addView(listView); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); dialog.show(); }
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * ?// www .ja va2s. co m * @param array * @param mCallback * @throws JSONException */ private void showModelChooseDialog(String[] array, final OnChooseModelFinished mCallback) throws JSONException { array[array.length - 1] = ""; View view1 = ((Activity) getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); final AlertDialog dialog = new AlertDialog.Builder(getContext()).setView(view1).create(); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); final ListView listView = new ListView(view1.getContext()); listView.setAdapter( new ArrayAdapter<String>(view1.getContext(), android.R.layout.simple_list_item_1, array)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { try { mCallback.onFinished(i); dialog.dismiss(); } catch (JSONException e) { e.printStackTrace(); } } }); contentArea.addView(listView); setTextView(view1, R.id.title, getResources().getString(R.string.select_model)); dialog.show(); }
From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealTabsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { v = inflater.inflate(R.layout.fragment_search_add_item_pager, container, false); // Change the status bar color if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window w = getActivity().getWindow(); w.setStatusBarColor(getResources().getColor(R.color.accent_dark)); }/*from w w w .java2 s . c o m*/ Bundle extras = getActivity().getIntent().getExtras(); if (extras != null) { mealType = extras.getString(Globals.MEAL_TYPE); page = extras.getInt("PAGE"); } card_search_manual = (CardView) v.findViewById(R.id.card_search_manual); card_search_fav = (CardView) v.findViewById(R.id.card_search_fav); // Initiate Toolbar Toolbar mToolbar = (Toolbar) v.findViewById(R.id.toolbar_search_main); ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mToolbar.getWindowToken(), 0); mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().finish(); } }); mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { if (menuItem.getItemId() == R.id.action_search) mCallbacks.searchClicked(); if (menuItem.getItemId() == R.id.action_manual) { Intent i = new Intent(getActivity(), ManualEntryActivity.class); i.putExtra(Globals.MEAL_TYPE, mealType); startActivity(i); } return false; } }); TextViewFont txtTitle = (TextViewFont) v.findViewById(R.id.txtTitle); if (txtTitle != null) txtTitle.setText(mealType); mToolbar.inflateMenu(R.menu.menu_search_add); // Hide keyboard ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(mToolbar.getWindowToken(), 0); // Initiate Pager and Tabs ChooseAddMealPagerAdapter myPagerAdapterAdd = new ChooseAddMealPagerAdapter(); ViewPager mViewPager = (ViewPager) v.findViewById(R.id.pager); TabLayout tabs = (TabLayout) v.findViewById(R.id.tabs); tabs.setTabTextColors(Color.parseColor("#80ffffff"), Color.parseColor("#ffffff")); tabs.setTabMode(TabLayout.MODE_SCROLLABLE); mViewPager.setAdapter(myPagerAdapterAdd); mViewPager.setOffscreenPageLimit(4); tabs.setupWithViewPager(mViewPager); mViewPager.setCurrentItem(page); // Initiate ListView and their adapters ListView mListRecentSearches = (ListView) v.findViewById(R.id.listRecentSearches); mListFavorites = (ListView) v.findViewById(R.id.listFavorites); listViewManual = (ListView) v.findViewById(R.id.listViewManual); llNoRecentFav = (LinearLayout) v.findViewById(R.id.llNoRecentFav); llNoRecentManual = (LinearLayout) v.findViewById(R.id.llNoRecentManual); llNoRecentSearch = (LinearLayout) v.findViewById(R.id.llNoRecentSearch); mRecentLogAdapter = new LogQuickSearchSimpleAdapter(getActivity(), 0, LogQuickSearch.all()); mListRecentSearches.setAdapter(mRecentLogAdapter); mListRecentSearches.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogQuickSearch recentLog = mRecentLogAdapter.getItem(position); mCallbacks.recentSearchClicked(recentLog.getName()); } }); mLogAdapterFavorite = new LogAdapterAll(getActivity(), 0, LogMeal.logSortByFavorite("favorite")); ViewGroup headerFav = (ViewGroup) inflater.inflate(R.layout.list_header_search_favorites, listViewManual, false); mListFavorites.addHeaderView(headerFav, null, false); mListFavorites.setAdapter(mLogAdapterFavorite); mListFavorites.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(searchManual.getWindowToken(), 0); LogMeal logMeal = mLogAdapterFavorite.getItem(position - 1); Intent i = new Intent(getActivity(), SaveSearchAddItemActivityMain.class); i.putExtra(Globals.MEAL_TYPE, mealType); i.putExtra(Globals.MEAL_ID, logMeal.getMealId()); i.putExtra(Globals.MEAL_BRAND, logMeal.getBrand()); i.putExtra(Globals.MEAL_FAVORITE, logMeal.getFavorite()); startActivity(i); } }); mLogAdapterManual = new LogAdapterManual(getActivity(), 0, LogManual.all(), mealType); ViewGroup header = (ViewGroup) inflater.inflate(R.layout.list_header_search, listViewManual, false); listViewManual.addHeaderView(header, null, false); listViewManual.setAdapter(mLogAdapterManual); listViewManual.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(searchManual.getWindowToken(), 0); LogManual logManual = mLogAdapterManual.getItem(position - 1); Intent i = new Intent(getActivity(), ManualEntrySaveMealActivity.class); i.putExtra(Globals.MEAL_TYPE, mealType); i.putExtra(Globals.MEAL_ID, logManual.getMealId()); startActivity(i); } }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { ((RelativeLayout.LayoutParams) card_search_manual.getLayoutParams()).setMargins(0, 0, 0, 0); // get rid of margins since shadow area is now the margin ((RelativeLayout.LayoutParams) card_search_fav.getLayoutParams()).setMargins(0, 0, 0, 0); // get rid of margins since shadow area is now the margin headerFav.setPadding(0, 0, 0, Equations.dpToPx(getActivity(), 16)); header.setPadding(0, 0, 0, Equations.dpToPx(getActivity(), 16)); } searchManualEntry(); searchFav(); /** * TODO RECIPE */ Button btnRecipe = (Button) v.findViewById(R.id.btnRecipe); btnRecipe.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LogRecipeHolder newRecipe = new LogRecipeHolder(); newRecipe.setDate(new Date()); newRecipe.setMealChoice(mealType); newRecipe.setMealName("Recipe"); newRecipe.save(); Intent i = new Intent(getActivity(), RecipeActivity.class); i.putExtra(Globals.MEAL_ID, newRecipe.getId()); i.putExtra(Globals.MEAL_TYPE, mealType); startActivity(i); } }); logAdapterMealRecipe = new LogRecipeHolderAdapter(getActivity(), 0, LogRecipeHolder.all()); listRecipes = (ListView) v.findViewById(R.id.listRecipes); listRecipes.setAdapter(logAdapterMealRecipe); listRecipes.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { LogRecipeHolder newRecipe = logAdapterMealRecipe.getItem(position); Intent i = new Intent(getActivity(), RecipeActivity.class); i.putExtra(Globals.MEAL_ID, newRecipe.getId()); i.putExtra(Globals.MEAL_TYPE, mealType); startActivity(i); } }); searchManual = (Button) v.findViewById(R.id.searchManual); searchManual.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleSearchManual(); } }); searchFavorite = (Button) v.findViewById(R.id.searchFav); searchFavorite.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { handleSearchFavorite(); } }); updateListView(); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(searchManual.getWindowToken(), 0); } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { } }); return v; }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);//from www . ja v a 2 s . c o m final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Auto discovery servers and add them in a list view. * Click a list item and make it as current server. * /* www . j a v a 2s. c o m*/ * @return the list view */ private ListView constructAutoServersView() { final ListView lv = new ListView(this); lv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200)); lv.setPadding(20, 5, 5, 10); lv.setBackgroundColor(0); lv.setCacheColorHint(0); lv.setItemsCanFocus(true); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(), R.layout.server_list_item, new ArrayList<String>()); lv.setAdapter(serverListAdapter); new IPAutoDiscoveryServer() { @Override protected void onProgressUpdate(Void... values) { if (progressLayout != null) { progressLayout.setVisibility(View.VISIBLE); } } @Override protected void onPostExecute(List<String> result) { int length = result.size(); for (int i = 0; i < length; i++) { serverListAdapter.add(result.get(i)); } if (length > 0) { lv.setItemChecked(0, true); currentServer = serverListAdapter.getItem(0); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); } if (progressLayout != null) { progressLayout.setVisibility(View.INVISIBLE); } requestPanelList(); checkAuthentication(); requestAccess(); } }.execute((Void) null); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { currentServer = (String) parent.getItemAtPosition(position); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); requestPanelList(); checkAuthentication(); requestAccess(); } }); return lv; }
From source file:com.example.search.car.pools.welcome.java
public void dialog(String name, final String[] arr, final TextView tv) { final Dialog dialog = new Dialog(welcome.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setContentView(R.layout.dialog); final ListView list = (ListView) dialog.findViewById(R.id.list_cities); DialogAdapter adapter = new DialogAdapter(welcome.this, arr); list.setAdapter(adapter); final TextView t = (TextView) dialog.findViewById(R.id.tv_1_send_msg); t.setText("Select " + name); Typeface tf = Typeface.createFromAsset(welcome.this.getAssets(), "AvenirLTStd_Book.otf"); t.setTypeface(tf);/* ww w . j a v a 2 s . co m*/ list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { tv.setText(arr[position]); dialog.dismiss(); } }); final RelativeLayout l_close = (RelativeLayout) dialog.findViewById(R.id.l_close); l_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog.show(); }
From source file:com.example.drugsformarinemammals.Listview_DrugResults.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_drugresults); helper = new Handler_Sqlite(this); Bundle extra = this.getIntent().getExtras(); if (extra.containsKey("drugList")) { //option Combined Search drugList = (ArrayList<String>) extra.get("drugList"); } else {/*from ww w . j a v a 2 s . c om*/ fiveLastScreen = (Boolean) extra.get("fiveLastScreen"); //option Five Last Searched orderDrugsByPriority(); } ListAdapter adapter = new ItemAdapterDrugResults(this, drugList); ListView listview = (ListView) findViewById(R.id.drugsresult); listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String drugName = drugList.get(position); if (!helper.existDrug(drugName)) { String[] urls = { "http://formmulary.tk/Android/getGeneralInfoDrug.php?drug_name=", "http://formmulary.tk/Android/getInfoCodes.php?drug_name=" }; boolean sync = false; new GetGeneralInfoDrug(drugName, sync).execute(urls); } else { Intent intent = new Intent(getApplicationContext(), General_Info_Drug.class); intent.putExtra("drugName", drugName); intent.putExtra("fiveLastScreen", fiveLastScreen); startActivity(intent); if (fiveLastScreen) finish(); } } }); listview.setAdapter(adapter); }