List of usage examples for android.widget ListView setAdapter
@Override public void setAdapter(ListAdapter adapter)
From source file:com.duguang.baseanimation.ui.listivew.listviews.GoogleCardsActivity.java
@Override public void initView() { ListView listView = (ListView) findViewById(R.id.activity_googlecards_listview); mGoogleCardsAdapter = new GoogleCardsAdapter(this); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView); listView.setAdapter(swingBottomInAnimationAdapter); mGoogleCardsAdapter.addAll(getItems()); }
From source file:com.bluetooth.mwoolley.microbitbledemo.ui.HrmListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_hrm_list); setButtonText();//from ww w . j a v a2 s . c om getSupportActionBar().setTitle(R.string.screen_title_main); showMsg(Utility.htmlColorGreen("Ready")); Settings.getInstance().restore(this); // connect to the Bluetooth service Intent gattServiceIntent = new Intent(this, HrmAdapterService.class); bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE); ble_device_list_adapter = new ListAdapter(); ListView listView = (ListView) this.findViewById(R.id.deviceList); listView.setAdapter(ble_device_list_adapter); ble_scanner = BleScannerFactory.getBleScanner(this.getApplicationContext()); ble_scanner.setDevice_name_start(null); ble_scanner.setSelect_bonded_devices_only(false); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (!service_connected) { showMsg("Not yet ready - try again soon"); return; } if (ble_scanning) { setScanState(false); ble_scanner.stopScanning(); } BluetoothDevice device = ble_device_list_adapter.getDevice(position); selected_device = device; connectToDevice(device); } }); }
From source file:com.example.tony.popularmovie.DetailActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mTrailerAdapter = new TrailerAdapter(getActivity(), null, 0); View rootView = inflater.inflate(R.layout.fragment_detail, container, false); View headerView = LayoutInflater.from(getActivity()).inflate(R.layout.list_view_header, null); View footerView = LayoutInflater.from(getActivity()).inflate(R.layout.list_view_footer, null); mTitle = (TextView) headerView.findViewById(R.id.movie_title); mReleaseDate = (TextView) headerView.findViewById(R.id.release_date); mRatings = (TextView) headerView.findViewById(R.id.movie_ratings); mOverview = (TextView) headerView.findViewById(R.id.movie_overview); mPoster = (ImageView) headerView.findViewById(R.id.movie_poster); mCheckBox = (CheckBox) headerView.findViewById(R.id.checkBox); ListView trailerListView = (ListView) rootView.findViewById(R.id.trailer_list); trailerListView.addHeaderView(headerView); trailerListView.addFooterView(footerView); trailerListView.setAdapter(mTrailerAdapter); trailerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override// w w w .j av a 2 s . c o m public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position == parent.getCount() - 1) { Intent intent = new Intent(getActivity(), ReviewActivity.class); intent.putExtra("movieID", mMovieId); getActivity().startActivity(intent); } else { Uri uri = Uri.parse(BASE_YOUTUBE_URL + sKey); Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri); getActivity().startActivity(intent); } } }); Bundle arguments = getArguments(); if (arguments != null) { trailerListView.setVisibility(View.VISIBLE); mMovieId = arguments.getString("movieID"); } else { trailerListView.setVisibility(View.GONE); } return rootView; }
From source file:com.daiv.android.twitter.settings.SettingsLinkDrawerClickListener.java
@Override public void onItemClick(AdapterView parent, View view, int position, long id) { Intent intent;// w w w . ja v a2 s. c o m final int mPos = position; if (mPos < 2) { // one of the settings pages new Handler().postDelayed(new Runnable() { @Override public void run() { mDrawerLayout.closeDrawer(Gravity.START); } }, 300); viewPager.setCurrentItem(mPos + 7, true); } else if (mPos == 2) { // changelog final ListView list = new ListView(context); list.setDividerHeight(0); new AsyncTask<Spanned[], Void, Spanned[]>() { @Override public Spanned[] doInBackground(Spanned[]... params) { return XmlChangelogUtils.parse(context); } @Override public void onPostExecute(Spanned[] result) { list.setAdapter(new ChangelogAdapter(context, result)); } }.execute(); new AlertDialog.Builder(context).setTitle(R.string.changelog).setView(list) .setPositiveButton(R.string.ok, null).show(); } else if (mPos == 3) { // rate it option new Handler().postDelayed(new Runnable() { @Override public void run() { Uri uri = Uri.parse("market://details?id=" + context.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { context.startActivity(goToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show(); } } }, 200); } }
From source file:com.example.droidcodin.popularmdb.MovieDetailFragment.java
private void fetchMovieVideos() { RestClient restclient = new RestClient(); restclient.getApiService().getVideo(mMovieID, apiKey, new Callback<VideoList>() { @Override/*from w ww . ja va2 s.c o m*/ public void success(VideoList videoList, Response response) { listOfVideos = videoList.getResults(); if (listOfVideos != null) { Utility.storeVideoList(getActivity(), mMovieID, listOfVideos); } ListView listView = (ListView) getView().findViewById(R.id.listview_video); mVideoAdapter = new VideoAdapter(getActivity(), listOfVideos); listView.setAdapter(mVideoAdapter); mFirstVideoStr = listOfVideos.get(0).getKey(); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { video = mVideoAdapter.getItem(position); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(youTubeBaseURL + video.getKey()))); } }); } @Override public void failure(RetrofitError error) { Log.e("failure", String.valueOf(error.getCause())); Toast.makeText(getActivity(), "Connection failed", Toast.LENGTH_LONG).show(); } }); }
From source file:com.esri.arcgisruntime.sample.transformsbysuitability.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the list of transformations final ListView tableList = findViewById(R.id.transforms_list); mTransformAdapter = new DatumTransformationAdapter(this, mTransformValues); tableList.setAdapter(mTransformAdapter); tableList.setOnItemClickListener((AdapterView<?> adapterView, View view, int i, long l) -> { view.setSelected(true);//from w w w.j a v a 2 s. co m // Get the datum transformation selected by the user DatumTransformation selectedTransform = (DatumTransformation) adapterView.getAdapter().getItem(i); Point projectedGeometry; try { // Use the selected transformation to reproject the Geometry projectedGeometry = (Point) GeometryEngine.project(mOriginalGeometry, mMapView.getSpatialReference(), selectedTransform); } catch (ArcGISRuntimeException agsEx) { // Catch errors thrown from project method. If a transformation is missing grid files, then it cannot be // successfully used to project a geometry, and will throw an exception. Snackbar.make(tableList, agsEx.getMessage() + "\n" + getResources().getString(R.string.transform_missing_files), Snackbar.LENGTH_LONG).show(); removeProjectedGeometryGraphic(); return; } // Add projected geometry as a second graphic - use a cross symbol which ensures the default transformation // graphic remains visible beneath this graphic. if (mProjectedGraphic == null) { mProjectedGraphic = addGraphic(projectedGeometry, Color.argb(255, 255, 0, 0), SimpleMarkerSymbol.Style.CROSS); } else { // If graphic already set, just update the geometry mProjectedGraphic.setGeometry(projectedGeometry); } }); // If the CheckBox is not checked (default), transformations should be ordered by suitability for the whole // spatial reference. If checked, then transformations will be ordered by suitability for the map extent. CheckBox checkBox = findViewById(R.id.order_by_check_box); checkBox.setOnCheckedChangeListener((CompoundButton compoundButton, boolean newCheckState) -> { // Store the new check state in a member variable and update the list of transformations. mUseExtentForSuitability = newCheckState; setupTransformsList(); }); // Get MapView from layout and set a map into this view mMapView = findViewById(R.id.mapView); mArcGISMap = new ArcGISMap(Basemap.createLightGrayCanvas()); mMapView.setMap(mArcGISMap); // Create a geometry located in the Greenwich observatory courtyard in London, UK, the location of the // Greenwich prime meridian. This will be projected using the selected transformation. mOriginalGeometry = new Point(538985.355, 177329.516, SpatialReference.create(27700)); // Add a Graphic to show the original geometry location, projected using the default transformation addGraphic(mOriginalGeometry, Color.argb(255, 0, 0, 255), SimpleMarkerSymbol.Style.SQUARE); mArcGISMap.addDoneLoadingListener(() -> { if (mArcGISMap.getLoadStatus() == LoadStatus.LOADED) { if (mTransformValues.size() == 0) { // Zoom to the initial default geometry at a suitable scale Viewpoint vp = new Viewpoint(mOriginalGeometry, 5000); mMapView.setViewpointAsync(vp, 2); // Once the map has loaded (which means the 'from' spatial reference is set), trigger populating the list // of transformations. Start by checking app has permissions to access local file storage, where projection // engine files for grid-based transformations are stored. checkPermissions(); } } }); }
From source file:com.liferay.alerts.activity.CommentsActivity.java
private void _registerBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_ADD_COMMENT); filter.addAction(ACTION_UPDATE_COMMENTS_LIST); _receiver = new BroadcastReceiver() { @Override// www . j a v a 2 s.c o m public void onReceive(Context context, Intent intent) { String action = intent.getAction(); ListView listView = (ListView) findViewById(R.id.comments); if (ACTION_UPDATE_COMMENTS_LIST.equals(action)) { ArrayList<Alert> alerts = intent.getParcelableArrayListExtra(EXTRA_ALERTS); ArrayAdapter<Alert> adapter = new CommentListAdapter(getApplicationContext(), alerts); listView.setAdapter(adapter); } else if (ACTION_ADD_COMMENT.equals(action)) { Alert alert = intent.getParcelableExtra(EXTRA_ALERT); ArrayAdapter<Alert> adapter = (ArrayAdapter<Alert>) listView.getAdapter(); adapter.add(alert); } } }; _getBroadcastManager().registerReceiver(_receiver, filter); }
From source file:org.flakor.androidtool.net.net.HistoryTask.java
@Override protected void onPostExecute(Integer i) { if (i < 0) { if (dialog != null) dialog.dismiss();//from www . j a v a 2 s. c o m Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); } else if (i >= 0) { View view = LayoutInflater.from(context).inflate(R.layout.dialog_history, null); ListView list = (ListView) view.findViewById(R.id.history_list); if (i == 0) { TextView noHistory = (TextView) view.findViewById(R.id.no_history); noHistory.setVisibility(View.VISIBLE); list.setVisibility(View.GONE); } else { RemoteHistoryAdapter adapter = new RemoteHistoryAdapter(context); list.setAdapter(adapter); } TextView title = (TextView) view.findViewById(R.id.dialog_title); title.setText("??"); Button okBtn = (Button) view.findViewById(R.id.ok_btn); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.setContentView(view); Toast.makeText(context, "??", Toast.LENGTH_SHORT).show(); } else { if (dialog != null) dialog.dismiss(); Toast.makeText(context, "???", Toast.LENGTH_SHORT).show(); } }
From source file:com.bluetooth.mwoolley.microbitbledemo.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setButtonText();// ww w .j av a2s. c o m getSupportActionBar().setTitle(R.string.screen_title_main); showMsg(Utility.htmlColorGreen("Ready")); Settings.getInstance().restore(this); ble_device_list_adapter = new ListAdapter(); ListView listView = (ListView) this.findViewById(R.id.deviceList); listView.setAdapter(ble_device_list_adapter); registerReceiver(broadcastReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); ble_scanner = BleScannerFactory.getBleScanner(this.getApplicationContext()); ble_scanner.setDevice_name_start(DEVICE_NAME_START); ble_scanner.setSelect_bonded_devices_only(true); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (ble_scanning) { setScanState(false); ble_scanner.stopScanning(); } BluetoothDevice device = ble_device_list_adapter.getDevice(position); if (device.getBondState() == BluetoothDevice.BOND_NONE && Settings.getInstance().isFilter_unpaired_devices()) { device.createBond(); showMsg(Utility.htmlColorRed("Selected micro:bit must be paired - pairing now")); return; } try { MainActivity.this.unregisterReceiver(broadcastReceiver); } catch (Exception e) { // ignore! } if (toast != null) { toast.cancel(); } MicroBit microbit = MicroBit.getInstance(); microbit.setBluetooth_device(device); Intent intent = new Intent(MainActivity.this, MenuActivity.class); intent.putExtra(MenuActivity.EXTRA_NAME, device.getName()); intent.putExtra(MenuActivity.EXTRA_ID, device.getAddress()); startActivity(intent); } }); }
From source file:com.brq.wallet.lt.activity.buy.AdSearchFragment.java
private void updateUi() { if (!isAdded()) { return;/*from ww w .j av a2 s .c o m*/ } ((TextView) findViewById(R.id.tvLocation)).setText(_ltManager.getUserLocation().name); if (_ads == null) { findViewById(R.id.pbWait).setVisibility(View.VISIBLE); findViewById(R.id.tvSearching).setVisibility(View.VISIBLE); findViewById(R.id.lvRecords).setVisibility(View.GONE); } else { findViewById(R.id.pbWait).setVisibility(View.GONE); findViewById(R.id.tvSearching).setVisibility(View.GONE); findViewById(R.id.lvRecords).setVisibility(View.VISIBLE); _recordsAdapter = new AdAdapter(getActivity(), _ads, _ltManager.useMiles()); ListView listView = (ListView) findViewById(R.id.lvRecords); listView.setAdapter(_recordsAdapter); } }