List of usage examples for android.widget ListView getAdapter
@Override
public ListAdapter getAdapter()
From source file:com.TomatoSauceStudio.OnTimeBirthdayPost.OnTimeBirthdayPost.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); /**/*w ww . ja v a 2s . c om*/ * On item click, just launch browser to go to friend's wall; * can't get the native Fb app intent to work all the time, so disabling that for now. */ String uid = ((CursorAdapter) l.getAdapter()).getCursor().getString(4); String uri = "http://facebook.com/" + uid; //"facebook://facebook.com/wall?user=" + uid; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); try { startActivity(intent); } catch (ActivityNotFoundException ae) { //TODO } }
From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java
/** * Function to set the tags that will be present in the test */// w ww . j a v a 2 s . c o m private void setTags() { ListView checkBoxesList = (ListView) findViewById(R.id.testTagsList); TagsArrayAdapter tagsAdapter = (TagsArrayAdapter) checkBoxesList.getAdapter(); int childsCount = checkBoxesList.getCount(); SparseBooleanArray checkedItems = checkBoxesList.getCheckedItemPositions(); tagsList = new ArrayList<TestTag>(); //If "All tags" item checked, add the whole list to the list of selected tags if (checkedItems.get(0, false)) { tagsList.add(new TestTag(0, null, "all", 0)); //If "All tags" item is not checked, add the selected items to the list of selected tags } else { for (int i = 0; i < childsCount; i++) { if (checkedItems.get(i, false)) { tagsList.add(tagsAdapter.getItem(i)); } } } if (isDebuggable) { Log.d(TAG, "tagsList=" + tagsList.toString()); } //If no tags selected, show a message to notice user if (tagsList.isEmpty()) { Toast.makeText(getApplicationContext(), R.string.testNoTagsSelectedMsg, Toast.LENGTH_LONG).show(); //If any tag is selected, show the answer types selection screen } else { selectAnswerTypes(); } }
From source file:net.naonedbus.fragment.CustomInfiniteListFragement.java
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final ListView listView = getListView(); mLoaderView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_loader, null); mLoaderView.setEnabled(false);/* w w w .j a v a 2 s .c o m*/ mLoaderView.setClickable(false); mLoaderView.setFocusable(false); mLoaderView.setFocusableInTouchMode(false); addOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(final AbsListView view, final int scrollState) { } @Override public void onScroll(final AbsListView view, final int firstVisibleItem, final int visibleItemCount, final int totalItemCount) { final int lastInScreen = firstVisibleItem + visibleItemCount; if ((lastInScreen == totalItemCount) && listView.getAdapter() != null && !mHasError) { onLoadMoreItems(); } else if (lastInScreen < totalItemCount) { mHasError = false; mLoaderView.setVisibility(View.VISIBLE); } } }); listView.addFooterView(mLoaderView); }
From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java
/** * Function to set the answer types that will be present in the test */// w w w . j a v a 2 s . co m private void setAnswerTypes() { ListView checkBoxesList = (ListView) findViewById(R.id.testAnswerTypesList); AnswerTypesArrayAdapter answerTypesAdapter = (AnswerTypesArrayAdapter) checkBoxesList.getAdapter(); int childsCount = checkBoxesList.getCount(); SparseBooleanArray checkedItems = checkBoxesList.getCheckedItemPositions(); answerTypesList = new ArrayList<String>(); /* * If "All tags" item checked, add the whole list to the list of selected answer types, * else, add the selected items to the list of selected answer types */ if (checkedItems.get(0, false)) { answerTypesList.add("all"); } else { for (int i = 1; i < childsCount; i++) { if (checkedItems.get(i, false)) { answerTypesList.add((String) answerTypesAdapter.getItem(i)); } } } if (isDebuggable) { Log.d(TAG, "answerTypesList=" + answerTypesList.toString()); } //If no answer types selected, show a message to notice user if (answerTypesList.isEmpty()) { Toast.makeText(getApplicationContext(), R.string.testNoAnswerTypesSelectedMsg, Toast.LENGTH_LONG) .show(); //If any answer type is selected, generate the test and show the first question screen } else { makeTest(); } }
From source file:com.tweetlanes.android.core.view.DirectMessageFeedFragment.java
@Override public void onJumpToTop() { if (mConversationListView != null) { ListView listView = mConversationListView.getRefreshableView(); if (listView != null && listView.getAdapter() != null && !listView.getAdapter().isEmpty()) { listView.setSelection(0);// w ww . j a v a 2s. c om } } }
From source file:com.lvfq.rabbit.swipe.DanceFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); listView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), false, true, new AbsListView.OnScrollListener() { @Override/* w w w. j av a 2 s. c om*/ public void onScrollStateChanged(AbsListView arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //Log.d(TAG, "first:"+firstVisibleItem+" visible:"+visibleItemCount+" total:"+totalItemCount+" last:"+listView.getLastVisiblePosition()); if (isNetworkConnected() && listView.getLastVisiblePosition() >= 0 && listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1 && listView.getChildAt(listView.getChildCount() - 1).getBottom() <= listView .getHeight()) { synchronized (canLoadMore) { Log.d(TAG, "load more"); canLoadMore = false; new DanceLoadMoreBackgroundTask().execute(); } } } })); if (rabbitAdapter.orderListRabbitData == null) initiateRefresh(); }
From source file:com.lvfq.rabbit.swipe.NewsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); final ListView listView = getListView(); listView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), false, true, new AbsListView.OnScrollListener() { @Override// w w w.ja va 2 s . c o m public void onScrollStateChanged(AbsListView arg0, int arg1) { // TODO Auto-generated method stub } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //Log.d(TAG, "first:"+firstVisibleItem+" visible:"+visibleItemCount+" total:"+totalItemCount+" last:"+listView.getLastVisiblePosition()); if (isNetworkConnected() && listView.getLastVisiblePosition() >= 0 && listView.getLastVisiblePosition() == listView.getAdapter().getCount() - 1 && listView.getChildAt(listView.getChildCount() - 1).getBottom() <= listView .getHeight()) { synchronized (canLoadMore) { Log.d(TAG, "load more"); canLoadMore = false; new NewsLoadMoreBackgroundTask().execute(); } } } })); if (rabbitAdapter.orderListRabbitData == null) initiateRefresh(); }
From source file:hu.fnf.devel.atlas.Atlas.java
public void addCat(View view) { Spinner spinner = (Spinner) findViewById(R.id.taskSpinner); // In case of null add! if (spinner.getSelectedItem() == null) { Log.d("Atlas", "null selection"); return;/*from w w w . j a v a 2 s. c om*/ } String selected = (String) spinner.getSelectedItem(); /* * add to list */ Category sel = categories.get(selected); Log.d("Atlas", "selected: " + selected); Log.d("Atlas", "id: " + sel.getId()); ListView cats = (ListView) findViewById(R.id.taskCats); CatAddAdapter catAddAdapter = (CatAddAdapter) cats.getAdapter(); if (catAddAdapter.getSum() >= (int) (catAddAdapter.getAmount()) + Integer.valueOf(sel.getAmount())) { AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this); myAlertDialog.setTitle("--- Task ---"); myAlertDialog.setMessage("Nothing left to categorize"); myAlertDialog.setPositiveButton(getResources().getString(R.string.ok), AtlasData.ackClick); myAlertDialog.show(); return; } catAddAdapter.add(new Category(sel.getId(), sel.getName(), sel.getAmount(), sel.getDepth(), sel.getColorr(), sel.getColorg(), sel.getColorb())); cats.setAdapter(catAddAdapter); //remove from spinner ArrayList<String> array_spinner = new ArrayList<String>(); int spin_count = spinner.getAdapter().getCount(); Log.d("Atlas", "spinner count: " + spin_count); if (spin_count == 1) { // no more category in spinner (ASANA: mi legyen ha elfogy a spinner) Log.d("Atlas", "no more category in spinner"); ImageView add = (ImageView) findViewById(R.id.taskAdd); add.setVisibility(View.INVISIBLE); add.setEnabled(false); spinner.setVisibility(View.INVISIBLE); spinner.setEnabled(false); } for (int i = 0; i < spin_count; i++) { String s = (String) spinner.getAdapter().getItem(i); if (!s.equalsIgnoreCase(selected)) { array_spinner.add(s); } } ArrayAdapter<String> arrayadapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.custom_simple_spinner, array_spinner); spinner.setAdapter(arrayadapter); }
From source file:hu.fnf.devel.atlas.Atlas.java
@SuppressLint("SimpleDateFormat") public void saveTask(View v) { ListView cats = (ListView) findViewById(R.id.taskCats); if (cats.getAdapter().getCount() == 0) { AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this); myAlertDialog.setTitle("--- Task ---"); myAlertDialog.setMessage("Add some category to save data!"); myAlertDialog.setPositiveButton("OK", AtlasData.ackClick); myAlertDialog.show();/*from ww w . ja va2 s.com*/ return; } TextView amount = (TextView) findViewById(R.id.taskAmount); TextView id = (TextView) findViewById(R.id.id); TextView tag = (TextView) findViewById(R.id.tag); TextView from = (TextView) findViewById(R.id.taskFrom); TextView to = (TextView) findViewById(R.id.taskTo); TextView date = (TextView) findViewById(R.id.taskDate); if (id.getText().toString().equalsIgnoreCase("-1")) { tag.setText(from.getText()); // we need the same tag, as in the transaction the from /* * if this is a manual transaction we need to insert to the transaction table */ int transid = (amount.getText().toString() + from.getText().toString() + to.getText().toString()) .hashCode(); AtlasParseSMSTask.insert(new Transaction(Math.abs(transid) * -1, // negative "random" id amount.getText().toString(), from.getText().toString(), to.getText().toString(), date.getText().toString(), // data format yyyy.MM.dd HH:mm String.valueOf(AtlasData.MANUAL_TRANSACTION), // typeid null, // smsid null)); // impossible hash id.setText(String.valueOf(Math.abs(transid) * -1)); // to be able to find this transaction when inserting data?? } CatAddAdapter cat_adapter = (CatAddAdapter) cats.getAdapter(); /* * check data not to save with more amount or less amount */ Log.d("Atlas", "amount: " + amount.getText().toString()); double sum = 0; for (int i = 0; i < cat_adapter.getCount(); i++) { sum += Double.valueOf(cat_adapter.getItem(i).getAmount()); } if (sum > Double.valueOf(amount.getText().toString())) { AlertDialog.Builder toomuchdialog = new AlertDialog.Builder(this); toomuchdialog.setTitle("--- Task ---"); toomuchdialog.setMessage("You can only categorize " + amount.getText() + "!"); toomuchdialog.setPositiveButton("OK", AtlasData.ackClick); toomuchdialog.show(); changeViewLevel(R.layout.detail_view, AtlasData.PSUMMARY, (int) (-1 * Double.valueOf(amount.getText().toString()))); } else if (sum < Double.valueOf(amount.getText().toString())) { AlertDialog.Builder toomuchdialog = new AlertDialog.Builder(this); toomuchdialog.setTitle("--- Task ---"); toomuchdialog.setMessage("You should categorize all " + amount.getText() + "!"); toomuchdialog.setPositiveButton("OK", AtlasData.ackClick); toomuchdialog.show(); changeViewLevel(R.layout.detail_view, AtlasData.PSUMMARY, (int) (-1 * Double.valueOf(amount.getText().toString()))); } else { if (cat_adapter.getCount() == 1) { /* * if only one category, than I guess other transactions are * also this one category */ AtlasParseSMSTask.insert(new Data(String.valueOf(tag.getText()), String.valueOf(id.getText()), cat_adapter.getItem(0).getId(), cat_adapter.getItem(0).getAmount(), String.valueOf(AtlasData.DONE))); Builder builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_TRANSACTIONS); builder.appendPath("tasks"); builder.appendPath("tag"); builder.appendQueryParameter(AtlasData.DATA_COLUMNS[AtlasData.DATA_TAG], String.valueOf(tag.getText())); Cursor trswithtag = getContentResolver().query(builder.build(), AtlasData.TRANSACTIONS_COLUMNS, null, null, null); if (trswithtag != null && trswithtag.moveToFirst()) { do { if (!String.valueOf(id.getText()) .equalsIgnoreCase(trswithtag.getString(AtlasData.TRANSACTIONS_ID)) && trswithtag.getInt(AtlasData.TRANSACTIONS_STATUS) == 0) { AtlasParseSMSTask.insert(new Data(String.valueOf(tag.getText()), trswithtag.getString(AtlasData.TRANSACTIONS_ID), cat_adapter.getItem(0).getId(), trswithtag.getString(AtlasData.TRANSACTIONS_AMOUNT), String.valueOf(AtlasData.FRESH))); } } while (trswithtag.moveToNext()); trswithtag.close(); } } else { /* * many categories...too complex transaction to suggest that all * others are the same */ for (int i = 0; i < cat_adapter.getCount(); i++) { AtlasParseSMSTask.insert(new Data(String.valueOf(tag.getText()), String.valueOf(id.getText()), cat_adapter.getItem(i).getId(), cat_adapter.getItem(i).getAmount(), String.valueOf(AtlasData.DONE))); } } changeViewLevel(R.layout.category_view, AtlasData.peekPos().page); } }
From source file:com.mobicage.rogerthat.AddFriendsActivity.java
private Bitmap getAvatar(final Contact c, int type) { Bitmap avatar;/*from w w w.j a v a 2s . c o m*/ switch (type) { case TYPE_AB_MATCH: case TYPE_SMS: case TYPE_MAIL: avatar = mPhoneContacts.getAvatar(c); break; case TYPE_FB_MATCH: final FacebookContact fbc = (FacebookContact) c; if (mFbAvatars.containsKey(fbc.email)) { avatar = mFbAvatars.get(fbc.email); } else { avatar = null; // Load avatar in the background L.d("Downloading fb avatar: " + fbc.pictureUrl); mFbAvatars.put(fbc.email, null); new SafeAsyncTask<Object, Object, Object>() { @Override protected Object safeDoInBackground(Object... params) { try { return BitmapFactory .decodeStream((InputStream) new URL((String) params[0]).getContent()); } catch (MalformedURLException e) { L.bug("Could not download Facebook avatar: " + fbc.pictureUrl, e); } catch (IOException e) { L.bug("Could not download Facebook avatar: " + fbc.pictureUrl, e); } catch (Exception e) { L.bug("Could not download Facebook avatar: " + fbc.pictureUrl, e); } return null; }; @Override protected void safeOnPostExecute(Object result) { Bitmap bitmap = (Bitmap) result; if (bitmap != null) { mFbAvatars.put(fbc.email, bitmap); ListView listView = (ListView) findViewById(R.id.add_via_facebook_result); BaseAdapter adapter = (BaseAdapter) listView.getAdapter(); adapter.notifyDataSetChanged(); } } @Override protected void safeOnCancelled(Object result) { } @Override protected void safeOnProgressUpdate(Object... values) { } @Override protected void safeOnPreExecute() { }; }.execute(fbc.pictureUrl); } break; default: avatar = null; break; } if (avatar == null) avatar = mFriendsPlugin.getMissingFriendAvatarBitmap(); else avatar = ImageHelper.getRoundedCornerAvatar(avatar); return avatar; }