List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.example.venkatagovardhan.docorganizer.FolderActivity.java
@Override public void onClipboardContentsChange(Clipboard clipboard) { invalidateOptionsMenu();/*from w w w .j a va 2 s . c om*/ ListView clipboardListView = (ListView) findViewById(R.id.listClipboard); if (clipboard.isEmpty() && drawerLayout != null) drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, GravityCompat.END); else { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END); FileManagerApplication application = (FileManagerApplication) getApplication(); if (clipboardListView != null) { ClipboardFileAdapter clipboardFileAdapter = new ClipboardFileAdapter(this, clipboard, application.getFileIconResolver()); clipboardFileAdapter.setFontApplicator(fontApplicator); clipboardListView.setAdapter(clipboardFileAdapter); } } }
From source file:com.cachirulop.moneybox.activity.MainActivity.java
/** * Create left navigation drawer with the list of created moneyboxes. *///from w w w . j a v a 2 s . c o m private void createDrawer() { final ListView drawerList; _drawerAdapter = new MoneyboxAdapter(this); _drawerAdapter.setOnRowClickListener(new MoneyboxAdapter.OnRowClickListener() { public void onClick(int position) { selectMoneybox((Moneybox) _drawerAdapter.getItem(position)); } }); // _drawerAdapter.setCurrentMoneyboxId (Preferences.getLastMoneyboxId // (this)); getActionBar().setTitle(_drawerAdapter.getCurrentItem().getDescription()); drawerList = (ListView) findViewById(R.id.lvMoneyboxes); drawerList.setAdapter(_drawerAdapter); _drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); _drawerToggle = new ActionBarDrawerToggle(this, _drawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { setTotalVisibility(true); getActionBar().setTitle(_drawerAdapter.getCurrentItem().getDescription()); invalidateOptionsMenu(); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { setTotalVisibility(false); getActionBar().setTitle(getString(R.string.moneybox_select_moneybox)); updateMoneyboxesTotal(); drawerList.smoothScrollToPosition(_drawerAdapter.getPosition()); invalidateOptionsMenu(); } }; // Set the drawer toggle as the DrawerListener _drawerLayout.setDrawerListener(_drawerToggle); }
From source file:nmtysh.android.test.speedtest.SpeedTestActivity.java
/** Called when the activity is first created. */ @Override/*w w w . j a v a 2 s . c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ListView listView = (ListView) findViewById(android.R.id.list); urlEdit = (EditText) findViewById(R.id.url_address); Button button = (Button) findViewById(R.id.use_http_client); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { runHttpClient(); } }); button = (Button) findViewById(R.id.use_http_url_connection); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { runHttpURLConnection(); } }); list = new LinkedList<String>(); adapter = new ArrayAdapter<String>(this, R.layout.list, list); listView.setAdapter(adapter); }
From source file:org.quantumbadger.redreader.activities.InboxListingActivity.java
@Override public void onCreate(Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences) && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT; getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); final String title; isModmail = getIntent() != null && getIntent().getBooleanExtra("modmail", false); if (!isModmail) { title = getString(R.string.mainmenu_inbox); } else {/*from ww w . j a va 2 s. c om*/ title = getString(R.string.mainmenu_modmail); } OptionsMenuUtility.fixActionBar(this, title); headerItems = PrefsUtility.appearance_comment_header_items(this, sharedPreferences); headerItems.remove(PrefsUtility.AppearanceCommentHeaderItems.SCORE); final LinearLayout outer = new LinearLayout(this); outer.setOrientation(android.widget.LinearLayout.VERTICAL); if (solidblack) { outer.setBackgroundColor(Color.BLACK); } loadingView = new LoadingView(this, getString(R.string.download_waiting), true, true); notifications = new LinearLayout(this); notifications.setOrientation(android.widget.LinearLayout.VERTICAL); notifications.addView(loadingView); final ListView lv = new ListView(this); lv.setSmoothScrollbarEnabled(false); lv.setVerticalFadingEdgeEnabled(false); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final Object item = lv.getAdapter().getItem(position); if (item != null && item instanceof RedditPreparedInboxItem) { ((RedditPreparedInboxItem) item).handleInboxClick(InboxListingActivity.this); } } }); adapter = new InboxListingAdapter(this, this); lv.setAdapter(adapter); registerForContextMenu(lv); outer.addView(notifications); outer.addView(lv); makeFirstRequest(this); setContentView(outer); }
From source file:com.ymt.demo1.plates.exportConsult.ExportConsultMainActivity.java
protected void initNearlyHotConsult() { /*/*from w w w . jav a2s . c o m*/ ? ? */ ListView recListView = (ListView) findViewById(R.id.rec_consult_list_view); ListView hotListView = (ListView) findViewById(R.id.hot_consult_list_view); recList = new ArrayList<>(); hotList = new ArrayList<>(); recAdapter = new HotRecConsultAdapter(this, HotRecConsultAdapter.CONSULT_MAIN_TYPE); hotAdapter = new HotRecConsultAdapter(this, HotRecConsultAdapter.CONSULT_MAIN_TYPE); recAdapter.setHotList(recList); hotAdapter.setHotList(hotList); recListView.setAdapter(recAdapter); hotListView.setAdapter(hotAdapter); TextView newListBtn = (TextView) findViewById(R.id.nearly_consult); TextView hotListBtn = (TextView) findViewById(R.id.hot_consult); newListBtn.setOnClickListener(this); hotListBtn.setOnClickListener(this); //// TODO: 2015/11/3 ? recListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ConsultInfo consult = (ConsultInfo) recAdapter.getItem(position); Intent intent = new Intent(ExportConsultMainActivity.this, ConsultDetailActivity.class); intent.putExtra("cid", consult.getCid()); startActivity(intent); } }); hotListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ConsultInfo consult = (ConsultInfo) hotAdapter.getItem(position); Intent intent = new Intent(ExportConsultMainActivity.this, ConsultDetailActivity.class); intent.putExtra("cid", consult.getCid()); startActivity(intent); } }); }
From source file:arun.com.chromer.fragments.AboutFragment.java
private void populateData(View rootView) { ListView chromerList = (ListView) rootView.findViewById(R.id.about_app_version_list); ListView authorList = (ListView) rootView.findViewById(R.id.about_author_version_list); View daniel = rootView.findViewById(R.id.daniel); daniel.setOnClickListener(new View.OnClickListener() { @Override// w w w.java 2 s . c o m public void onClick(View v) { Intent googleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/u/0/+DanielCiao/about")); getActivity().startActivity(googleIntent); } }); // Loading the header chromerList.setAdapter(new ExtendedBaseAdapter() { final Context context = getActivity().getApplicationContext(); @Override public int getCount() { return 4; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater mInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false); holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image); holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle); holder.title = (TextView) convertView.findViewById(R.id.about_app_title); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } int materialdarkColor = ContextCompat.getColor(context, R.color.accent); holder.subtitle.setVisibility(View.VISIBLE); switch (position) { case 0: holder.title.setText(R.string.version); holder.subtitle.setText(Util.getPackageVersion(context)); holder.imageView.setBackground(new IconicsDrawable(context) .icon(GoogleMaterial.Icon.gmd_info_outline).color(materialdarkColor).sizeDp(24)); break; case 1: holder.title.setText(R.string.changelog); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground(new IconicsDrawable(context) .icon(GoogleMaterial.Icon.gmd_track_changes).color(materialdarkColor).sizeDp(24)); break; case 2: holder.title.setText(R.string.join_google_plus); holder.subtitle.setText(R.string.share_ideas); holder.imageView.setBackground( new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles_communities) .color(materialdarkColor).sizeDp(24)); break; case 3: holder.title.setText(R.string.licenses); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground(new IconicsDrawable(context) .icon(GoogleMaterial.Icon.gmd_card_membership).color(materialdarkColor).sizeDp(24)); break; } return convertView; } }); authorList.setAdapter(new ExtendedBaseAdapter() { final Context context = getActivity().getApplicationContext(); @Override public int getCount() { return 5; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater mInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false); holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image); holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle); holder.title = (TextView) convertView.findViewById(R.id.about_app_title); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } switch (position) { case 0: holder.title.setText(StringConstants.ME); holder.subtitle.setText(StringConstants.LOCATION); holder.imageView.getLayoutParams().height = (int) getResources() .getDimension(R.dimen.arun_height); holder.imageView.getLayoutParams().width = (int) getResources() .getDimension(R.dimen.arun_width); Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arun); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory .create(getResources(), imageBitmap); roundedBitmapDrawable.setAntiAlias(true); roundedBitmapDrawable.setCircular(true); holder.imageView.setImageDrawable(roundedBitmapDrawable); break; case 1: holder.title.setText(R.string.add_to_circles); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground( new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles) .color(ContextCompat.getColor(getActivity(), R.color.google_plus)).sizeDp(24)); break; case 2: holder.title.setText(R.string.follow_twitter); holder.subtitle.setVisibility(View.GONE); holder.imageView .setBackground(new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_twitter) .color(ContextCompat.getColor(getActivity(), R.color.twitter)).sizeDp(24)); break; case 3: holder.title.setText(R.string.connect_linkedIn); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground( new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_linkedin_box) .color(ContextCompat.getColor(getActivity(), R.color.linkedin)).sizeDp(24)); break; case 4: holder.title.setText(R.string.more_apps); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground(new IconicsDrawable(context) .icon(CommunityMaterial.Icon.cmd_google_play) .color(ContextCompat.getColor(getActivity(), R.color.playstore_green)).sizeDp(24)); break; } return convertView; } }); chromerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: return; case 1: ChangelogUtil.showChangelogDialog(getActivity()); break; case 2: Intent googleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/communities/109754631011301174504")); getActivity().startActivity(googleIntent); break; case 3: new LicensesDialog.Builder(getActivity()).setNotices(Licenses.getNotices()) .setTitle(R.string.licenses).build().showAppCompat(); break; } } }); authorList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: return; case 1: Intent googleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com/+arunkumar5592")); getActivity().startActivity(googleIntent); break; case 2: Intent twitterIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/arunkumar_9t2")); getActivity().startActivity(twitterIntent); break; case 3: Intent linkedinIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://in.linkedin.com/in/arunkumar9t2")); getActivity().startActivity(linkedinIntent); break; case 4: try { getActivity().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Arunkumar"))); } catch (android.content.ActivityNotFoundException anfe) { getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/search?q=pub:Arunkumar"))); } break; } } }); }
From source file:org.deviceconnect.android.manager.setting.ReqResDebugActivity.java
/** * UI??.//w ww.j a va 2 s. c o m */ private void initUI() { // ? mListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); // ListView listView = (ListView) findViewById(R.id.reqResList); listView.setAdapter(mListAdapter); initSpinner(); // ? mTextPath = (EditText) findViewById(R.id.reqPath); // URL? mSelectUrl = (CheckBox) findViewById(R.id.isUrl); mSelectUrl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { enableSetting(buttonView.isChecked()); } }); mWebsocketBtn = (ToggleButton) findViewById(R.id.reqWesocket); mWebsocketBtn.setOnClickListener(this); }
From source file:com.maskyn.fileeditorpro.dialogfragment.FileInfoDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View view = new DialogHelper.Builder(getActivity()).setTitle(R.string.info) .setView(R.layout.dialog_fragment_file_info).createSkeletonView(); //final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_fragment_file_info, null); ListView list = (ListView) view.findViewById(android.R.id.list); DocumentFile file = DocumentFile.fromFile( new File(AccessStorageApi.getPath(getActivity(), (Uri) getArguments().getParcelable("uri")))); if (file == null && Device.hasKitKatApi()) { file = DocumentFile.fromSingleUri(getActivity(), (Uri) getArguments().getParcelable("uri")); }/*from www.java2 s .co m*/ // Get the last modification information. Long lastModified = file.lastModified(); // Create a new date object and pass last modified information // to the date object. Date date = new Date(lastModified); String[] lines1 = { getString(R.string.name), //getString(R.string.folder), getString(R.string.size), getString(R.string.modification_date) }; String[] lines2 = { file.getName(), //file.getParent(), FileUtils.byteCountToDisplaySize(file.length()), date.toString() }; list.setAdapter(new AdapterTwoItem(getActivity(), lines1, lines2)); return new AlertDialog.Builder(getActivity()).setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); }
From source file:com.agustinprats.myhrv.fragment.MonitorFragment.java
/** Shows the connect dialog displaying a list of available devices to connect */ private void showConnectDialog() { LayoutInflater inflater = getMainActivity().getLayoutInflater(); // Init view/*from w w w . j av a2s .co m*/ RelativeLayout devicesDialogView = (RelativeLayout) inflater.inflate(R.layout.devices_dialog, null); AlertDialog.Builder devicesDialogBuilder = new AlertDialog.Builder(getMainActivity()); devicesDialogBuilder.setTitle(R.string.devices_available); devicesDialogBuilder.setView(devicesDialogView); final AlertDialog devicesDialog = devicesDialogBuilder.create(); _searchingDevicesText = (TextView) devicesDialogView.findViewById(R.id.searchingText); ListView listView = (ListView) devicesDialogView.findViewById(R.id.listView); listView.setEmptyView(_searchingDevicesText); final HeartRateDeviceListAdapter mHeartRateDeviceListAdapter = new HeartRateDeviceListAdapter(inflater); _heartRateDeviceListAdapter = mHeartRateDeviceListAdapter; final HeartRateService service = getMainActivity().getHeartRateService(); service.startScanningDevices(); listView.setAdapter(mHeartRateDeviceListAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final HeartRateDevice device = mHeartRateDeviceListAdapter.getDevice(position); if (device != null) { if (service.isScanning()) service.stopScanningDevices(); Log.d(TAG, "connecting from devices dialog"); service.connect(device.getAddress()); } devicesDialog.dismiss(); } }); devicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { service.stopScanningDevices(); _heartRateDeviceListAdapter = null; } }); devicesDialog.show(); }
From source file:android.support.v7.app.AlertController.java
private void setupView() { final View parentPanel = mWindow.findViewById(R.id.parentPanel); final View defaultTopPanel = parentPanel.findViewById(R.id.topPanel); final View defaultContentPanel = parentPanel.findViewById(R.id.contentPanel); final View defaultButtonPanel = parentPanel.findViewById(R.id.buttonPanel); // Install custom content before setting up the title or buttons so // that we can handle panel overrides. final ViewGroup customPanel = (ViewGroup) parentPanel.findViewById(R.id.customPanel); setupCustomContent(customPanel);// w ww .j a v a2s.c o m final View customTopPanel = customPanel.findViewById(R.id.topPanel); final View customContentPanel = customPanel.findViewById(R.id.contentPanel); final View customButtonPanel = customPanel.findViewById(R.id.buttonPanel); // Resolve the correct panels and remove the defaults, if needed. final ViewGroup topPanel = resolvePanel(customTopPanel, defaultTopPanel); final ViewGroup contentPanel = resolvePanel(customContentPanel, defaultContentPanel); final ViewGroup buttonPanel = resolvePanel(customButtonPanel, defaultButtonPanel); setupContent(contentPanel); setupButtons(buttonPanel); setupTitle(topPanel); final boolean hasCustomPanel = customPanel != null && customPanel.getVisibility() != View.GONE; final boolean hasTopPanel = topPanel != null && topPanel.getVisibility() != View.GONE; final boolean hasButtonPanel = buttonPanel != null && buttonPanel.getVisibility() != View.GONE; // Only display the text spacer if we don't have buttons. if (!hasButtonPanel) { if (contentPanel != null) { final View spacer = contentPanel.findViewById(R.id.textSpacerNoButtons); if (spacer != null) { spacer.setVisibility(View.VISIBLE); } } } if (hasTopPanel) { // Only clip scrolling content to padding if we have a title. if (mScrollView != null) { mScrollView.setClipToPadding(true); } } // Update scroll indicators as needed. if (!hasCustomPanel) { final View content = mListView != null ? mListView : mScrollView; if (content != null) { final int indicators = (hasTopPanel ? ViewCompat.SCROLL_INDICATOR_TOP : 0) | (hasButtonPanel ? ViewCompat.SCROLL_INDICATOR_BOTTOM : 0); setScrollIndicators(contentPanel, content, indicators, ViewCompat.SCROLL_INDICATOR_TOP | ViewCompat.SCROLL_INDICATOR_BOTTOM); } } final ListView listView = mListView; if (listView != null && mAdapter != null) { listView.setAdapter(mAdapter); final int checkedItem = mCheckedItem; if (checkedItem > -1) { listView.setItemChecked(checkedItem, true); listView.setSelection(checkedItem); } } }