List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.abewy.android.apps.openklyph.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*//from ww w.jav a 2s . c om * if (KlyphSession.getSessionUserName() != null) * { * loggedIn = true; * setTitle(KlyphSession.getSessionUserName()); * } * else * { * if (KlyphFlags.IS_PRO_VERSION == true) * setTitle(R.string.app_pro_name); * else * setTitle(R.string.app_name); * } */ setTitle(""); if (Session.getActiveSession() == null || KlyphSession.getSessionUserId() == null || (Session.getActiveSession() != null && Session.getActiveSession().isOpened() == false)) { getActionBar().hide(); getFragmentManager().beginTransaction().add(R.id.main, new LoginFragment(), FRAGMENT_TAG).commit(); } // notificationsFragment.setHasOptionsMenu(false); adContainer = (ViewGroup) findViewById(R.id.ad); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawerToggle = new ActionBarDrawerToggle(this, drawer, AttrUtil.getResourceId(this, R.attr.drawerIcon), R.string.open, R.string.close) { @Override public void onDrawerOpened(View view) { Log.d("MainActivity.onCreate(...).new ActionBarDrawerToggle() {...}", "onDrawerOpened: "); super.onDrawerOpened(view); Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (drawer.isDrawerOpen(Gravity.RIGHT)) { // drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, Gravity.RIGHT); if (notificationsFragment != null) { notificationsFragment.setHasOptionsMenu(true); notificationsFragment.onOpenPane(); } if (fragment != null) fragment.setHasOptionsMenu(false); } else if (drawer.isDrawerOpen(Gravity.LEFT)) { if (notificationsFragment != null) { notificationsFragment.setHasOptionsMenu(false); } if (fragment != null) fragment.setHasOptionsMenu(true); } invalidateOptionsMenu(); } @Override public void onDrawerClosed(View view) { super.onDrawerClosed(view); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT); if (!drawer.isDrawerOpen(Gravity.RIGHT)) { if (notificationsFragment != null) notificationsFragment.setHasOptionsMenu(false); Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG); if (fragment != null) fragment.setHasOptionsMenu(true); } invalidateOptionsMenu(); } }; drawer.setDrawerListener(drawerToggle); final List<String> labels = KlyphPreferences.getLeftDrawerMenuLabels(); classes = new ArrayList<String>(KlyphPreferences.getLeftDrawerMenuClasses()); classes.add("com.abewy.android.apps.openklyph.fragment.UserTimeline"); navAdapter = new DrawerLayoutAdapter(getActionBar().getThemedContext(), R.layout.item_drawer_layout, labels); final ListView navList = (ListView) findViewById(R.id.drawer); // Setting drawers max width int maxWidth = getResources().getDimensionPixelSize(R.dimen.max_drawer_layout_width); int w = Math.min(KlyphDevice.getDeviceWidth(), KlyphDevice.getDeviceHeight()) - getResources().getDimensionPixelSize(R.dimen.dip_64); int finalWidth = Math.min(maxWidth, w); LayoutParams params = ((View) navList.getParent()).getLayoutParams(); params.width = finalWidth; ((View) navList.getParent()).setLayoutParams(params); final View notificationContainer = findViewById(R.id.notifications_container); params = notificationContainer.getLayoutParams(); params.width = finalWidth; notificationContainer.setLayoutParams(params); // End max width navList.setFadingEdgeLength(0); navList.setVerticalFadingEdgeEnabled(false); navList.setAdapter(navAdapter); navList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) { updateContent(pos); drawer.closeDrawer(Gravity.LEFT); } }); // Try to use more data here. ANDROID_ID is a single point of attack. // String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID); // Library calls this when it's done. // mLicenseCheckerCallback = new MyLicenseCheckerCallback(); // Construct the LicenseChecker with a policy. // mChecker = new LicenseChecker(this, new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)), BASE64_PUBLIC_KEY); // mChecker.checkAccess(mLicenseCheckerCallback) // Facebook HashKey if (KlyphFlags.LOG_FACEBOOK_HASH) FacebookUtil.logHash(this); // Hierarchy View Connector if (KlyphFlags.ENABLE_HIERACHY_VIEW_CONNECTOR) HierachyViewUtil.connectHierarchyView(this); }
From source file:edu.cens.loci.ui.VisitDetailActivity.java
private void updateRecognitionList(ListView list, String jsonString) { try {//w w w. j a v a 2 s.c om JSONArray jArr = new JSONArray(jsonString); ArrayList<RecognitionResult> recogs = new ArrayList<RecognitionResult>(); LociDbUtils dbUtils = new LociDbUtils(this); long pid = -1; String pname = ""; for (int i = 0; i < jArr.length(); i++) { RecognitionResult recog = new RecognitionResult(jArr.getJSONObject(i)); if (pid != recog.placeId) { pid = recog.placeId; if (pid > 0) pname = dbUtils.getPlace(pid).name; else pname = "Unknown"; } recog.placeName = pname; recogs.add(recog); //recogs.add(new RecognitionResult(jArr.getJSONObject(i)).setPlaceName(dbUtils)); } //MyLog.e(true, TAG, "# of recog results returned : " + recogs.size()); RecogResultAdapter adapter = new RecogResultAdapter(this, R.layout.dialog_recogresult_item, recogs); list.setAdapter(adapter); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.audiokernel.euphonyrmt.MainMenuActivity.java
private ListView initializeDrawerList() { final ListView drawerList = (ListView) findViewById(R.id.left_drawer); final DrawerItem[] drawerItems = { new DrawerItem(getString(R.string.libraryTabActivity), DrawerItem.Action.ACTION_LIBRARY), new DrawerItem(getString(R.string.outputs), DrawerItem.Action.ACTION_OUTPUTS), new DrawerItem(getString(R.string.settings), DrawerItem.Action.ACTION_SETTINGS), new DrawerItem("Euphony Settings...", DrawerItem.Action.ACTION_LOON_CLIENT), new DrawerItem("Euphony File Manager...", DrawerItem.Action.ACTION_LOON_FM), new DrawerItem("Euphony Reboot", DrawerItem.Action.ACTION_LOON_REBOOT), new DrawerItem("Euphony Shutdown", DrawerItem.Action.ACTION_LOON_SHUTDOWN) }; // Set the adapter for the list view drawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, drawerItems)); drawerList.setItemChecked(mOldDrawerPosition, true); // Set the list's click listener drawerList.setOnItemClickListener(new DrawerItemClickListener()); return drawerList; }
From source file:com.hichinaschool.flashcards.anki.CardEditor.java
private StyledDialog createDialogIntentInformation(Builder builder, Resources res) { builder.setTitle(res.getString(R.string.intent_add_saved_information)); ListView listView = new ListView(this); mIntentInformationAdapter = new SimpleAdapter(this, mIntentInformation, R.layout.card_item, new String[] { "source", "target", "id" }, new int[] { R.id.card_sfld, R.id.card_tmpl, R.id.card_item }); listView.setAdapter(mIntentInformationAdapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override/*from ww w .j a va2s . c om*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(CardEditor.this, CardEditor.class); intent.putExtra(EXTRA_CALLER, CALLER_CARDEDITOR_INTENT_ADD); HashMap<String, String> map = mIntentInformation.get(position); intent.putExtra(EXTRA_CONTENTS, map.get("fields")); intent.putExtra(EXTRA_ID, map.get("id")); startActivityForResult(intent, REQUEST_INTENT_ADD); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(CardEditor.this, ActivityTransitionAnimation.FADE); } mIntentInformationDialog.dismiss(); } }); mCardItemBackground = Themes.getCardBrowserBackground()[0]; mIntentInformationAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { if (view.getId() == R.id.card_item) { view.setBackgroundResource(mCardItemBackground); return true; } return false; } }); listView.setBackgroundColor(android.R.attr.colorBackground); listView.setDrawSelectorOnTop(true); listView.setFastScrollEnabled(true); Themes.setContentStyle(listView, Themes.CALLER_CARDEDITOR_INTENTDIALOG); builder.setView(listView, false, true); builder.setCancelable(true); builder.setPositiveButton(res.getString(R.string.intent_add_clear_all), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { MetaDB.resetIntentInformation(CardEditor.this); mIntentInformation.clear(); dialog.dismiss(); } }); StyledDialog dialog = builder.create(); mIntentInformationDialog = dialog; return dialog; }
From source file:net.phase.wallet.Currency.java
public void updateWalletList() { if (wallets != null) { setContentView(R.layout.main);//from w w w .j a va2 s .co m ListView view = (ListView) findViewById(R.id.walletListView); WalletAdapter adapter = new WalletAdapter(this, wallets, decimalpoints); view.setAdapter(adapter); double exchrate = Currency.getRate(getActiveCurrency()); long balance = 0; for (int i = 0; i < wallets.length; i++) { balance += wallets[i].balance; } DecimalFormat df = new DecimalFormat(decimalString(decimalpoints)); TextView btcBalance = (TextView) findViewById(R.id.btcBalance); btcBalance.setText(df.format(balance / BalanceRetriever.SATOSHIS_PER_BITCOIN) + " BTC"); TextView curBalance = (TextView) findViewById(R.id.curBalance); if (exchrate != 0) { curBalance.setText(df.format(balance * exchrate / BalanceRetriever.SATOSHIS_PER_BITCOIN) + " " + getActiveCurrency()); } else { curBalance.setText(""); } registerForContextMenu(view); try { Wallet.saveWallets(wallets, this); } catch (IOException e) { toastMessage("Unable to save wallet data " + e.getMessage()); } } else { setContentView(R.layout.mainnowallets); } }
From source file:androidVNC.VncCanvasActivity.java
private void selectColorModel() { // Stop repainting the desktop // because the display is composited! vncCanvas.disableRepaints();//from w ww . j av a 2 s . co m String[] choices = new String[COLORMODEL.values().length]; int currentSelection = -1; for (int i = 0; i < choices.length; i++) { COLORMODEL cm = COLORMODEL.values()[i]; choices[i] = cm.toString(); if (vncCanvas.isColorModel(cm)) currentSelection = i; } final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); ListView list = new ListView(this); list.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, choices)); list.setChoiceMode(ListView.CHOICE_MODE_SINGLE); list.setItemChecked(currentSelection, true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { dialog.dismiss(); COLORMODEL cm = COLORMODEL.values()[arg2]; vncCanvas.setColorModel(cm); connection.setColorModel(cm.nameString()); connection.save(database.getWritableDatabase()); //Toast.makeText(VncCanvasActivity.this,"Updating Color Model to " + cm.toString(), Toast.LENGTH_SHORT).show(); } }); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { Log.i(TAG, "Color Model Selector dismissed"); // Restore desktop repaints vncCanvas.enableRepaints(); } }); dialog.setContentView(list); dialog.show(); }
From source file:de.geeksfactory.opacclient.frontend.AccountFragment.java
public void prolongAllDo() { MultiStepResultHelper<Void> msrhProlong = new MultiStepResultHelper<>(getActivity(), null, R.string.doing_prolong_all); msrhProlong.setCallback(new Callback<Void>() { @Override// w ww. j a v a2 s .c o m public void onSuccess(MultiStepResult result) { if (getActivity() == null) { return; } ProlongAllResult res = (ProlongAllResult) result; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getLayoutInflater(null); View view = inflater.inflate(R.layout.dialog_simple_list, null, false); ListView lv = (ListView) view.findViewById(R.id.lvBibs); lv.setAdapter(new ProlongAllResultAdapter(getActivity(), res.getResults())); switch (result.getActionIdentifier()) { case ReservationResult.ACTION_BRANCH: builder.setTitle(R.string.branch); } builder.setView(view).setNeutralButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { adialog.cancel(); invalidateData(); } }); adialog = builder.create(); adialog.show(); } @Override public void onError(MultiStepResult result) { if (getActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(result.getMessage()).setCancelable(true) .setNegativeButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface d, int id) { d.cancel(); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface d) { if (d != null) { d.cancel(); } } }); AlertDialog alert = builder.create(); alert.show(); } @Override public void onUnhandledResult(MultiStepResult result) { } @Override public void onUserCancel() { } @Override public StepTask<?> newTask(MultiStepResultHelper helper, int useraction, String selection, Void argument) { return new ProlongAllTask(helper, useraction, selection); } }); msrhProlong.start(); }
From source file:fr.univsavoie.ltp.client.map.Popup.java
public final void popupGetStatus(JSONArray pStatusesArray) { DisplayMetrics dm = new DisplayMetrics(); this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm); //final int height = dm.heightPixels; final int width = dm.widthPixels; final int height = dm.heightPixels; int popupWidth = (int) (width * 0.75); int popupHeight = height; // Inflate the popup_layout.xml ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupGetStatus); LayoutInflater layoutInflater = (LayoutInflater) this.activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View layout = layoutInflater.inflate(R.layout.popup_get_status, viewGroup); layout.setBackgroundResource(R.drawable.popup_gradient); // Crer le PopupWindow final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true); popupPublishStatus.setBackgroundDrawable(new BitmapDrawable()); popupPublishStatus.setOutsideTouchable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. final int OFFSET_X = 0; final int OFFSET_Y = 0; // Displaying the popup at the specified location, + offsets. this.activity.findViewById(R.id.layoutMain).post(new Runnable() { public void run() { popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y); }/*from w w w . j a va 2s. co m*/ }); /* * Evenements composants du PopupWindow */ // Find the ListView resource. ListView mainListView = (ListView) layout.findViewById(R.id.listViewStatus); ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>(); SimpleAdapter adapter = new SimpleAdapter(this.activity, list, R.layout.custom_row_view, new String[] { "content", "lat", "lon" }, new int[] { R.id.text1, R.id.text2, R.id.text3 }); try { // Appel REST pour recuperer les status de l'utilisateur connect //Session session = new Session(this.activity); //session.parseJSONUrl("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", "GET"); // Parser la liste des amis dans le OverlayItem ArrayList HashMap<String, String> temp; for (int i = 0; (i < 6); i++) { // Obtenir le status JSONObject status = pStatusesArray.getJSONObject(i); temp = new HashMap<String, String>(); temp.put("content", status.getString("content")); temp.put("lat", String.valueOf(status.getDouble("lat"))); temp.put("lon", String.valueOf(status.getDouble("lon"))); list.add(temp); } } catch (JSONException jex) { Log.e("Catch", "popupGetStatus / JSONException : " + jex.getStackTrace()); } catch (Exception ex) { Log.e("Catch", "popupGetStatus / Exception : " + ex.getLocalizedMessage()); } mainListView.setAdapter(adapter); }
From source file:com.abcvoipsip.ui.help.Help.java
public View getCustomView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.help, container, false); ListView lv = (ListView) v.findViewById(android.R.id.list); lv.setOnItemClickListener(this); ArrayList<HelpEntry> items = new ArrayList<HelpEntry>(); // FAQ/*from w w w .j a va2 s. co m*/ if (!TextUtils.isEmpty(CustomDistribution.getFaqLink())) { items.add(new HelpEntry(android.R.drawable.ic_menu_info_details, R.string.faq, FAQ)); } // Issue list if (CustomDistribution.showIssueList()) { items.add(new HelpEntry(android.R.drawable.ic_menu_view, R.string.view_existing_issues, OPEN_ISSUES)); } // Log collector // ABC-VoIP Modification: disable log collection and sending // since appears to be more confusing than useful. /* if(!TextUtils.isEmpty(CustomDistribution.getSupportEmail()) ) { if(isRecording()) { items.add(new HelpEntry( android.R.drawable.ic_menu_send , R.string.send_logs, SEND_LOGS)); } else { items.add(new HelpEntry( android.R.drawable.ic_menu_save , R.string.record_logs, START_LOGS)); } } */ items.add(new HelpEntry(android.R.drawable.ic_menu_gallery, R.string.legal_information, LEGALS)); // ABC-VoIP Modification: disable nightly updates, to avoid confusion in customers /* PackageInfo pinfo = PreferencesProviderWrapper.getCurrentPackageInfos(getActivity()); if(pinfo != null && pinfo.applicationInfo.icon == R.drawable.ic_launcher_nightly) { items.add(new HelpEntry(R.drawable.ic_launcher_nightly, R.string.update_nightly_build, NIGHTLY)); } */ lv.setAdapter(new HelpArrayAdapter(getActivity(), items)); TextView tv = (TextView) v.findViewById(android.R.id.text1); tv.setText(CollectLogs.getApplicationInfo(getActivity())); return v; }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Displays an alert dialog that allows the user to select applications from all non-system * applications installed on the current profile. After the user selects an app, this app can't * be uninstallation./*from w w w . j a v a 2 s . co m*/ */ private void showBlockUninstallationPrompt() { Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { return; } List<ApplicationInfo> applicationInfoList = mPackageManager.getInstalledApplications(0 /* No flag */); List<ResolveInfo> resolveInfoList = new ArrayList<ResolveInfo>(); Collections.sort(applicationInfoList, new ApplicationInfo.DisplayNameComparator(mPackageManager)); for (ApplicationInfo applicationInfo : applicationInfoList) { // Ignore system apps because they can't be uninstalled. if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.resolvePackageName = applicationInfo.packageName; resolveInfoList.add(resolveInfo); } } final BlockUninstallationInfoArrayAdapter blockUninstallationInfoArrayAdapter = new BlockUninstallationInfoArrayAdapter( getActivity(), R.id.pkg_name, resolveInfoList); ListView listview = new ListView(getActivity()); listview.setAdapter(blockUninstallationInfoArrayAdapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { blockUninstallationInfoArrayAdapter.onItemClick(parent, view, pos, id); } }); new AlertDialog.Builder(getActivity()).setTitle(R.string.block_uninstallation_title).setView(listview) .setPositiveButton(R.string.close, null /* Nothing to do */).show(); }