本文整理匯總了Java中android.widget.ListView.getCheckedItemPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.getCheckedItemPosition方法的具體用法?Java ListView.getCheckedItemPosition怎麽用?Java ListView.getCheckedItemPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListView
的用法示例。
在下文中一共展示了ListView.getCheckedItemPosition方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View getView(int position, final View convertView, ViewGroup parent) {
View view = convertView;
if (mParam.equals ("navigation_drawer")) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate (R.layout.custom_row_nav_item, parent, false);
TextView subjectName = (TextView) view.findViewById (R.id.textViewRow);
Typeface typeface = Typeface.createFromAsset (mContext.getAssets (), "font/Roboto_Medium.ttf");
subjectName.setTypeface (typeface);
subjectName.setText (mArrayList.get (position));
ImageView drawerItemIcon = (ImageView) view.findViewById (R.id.listIcon);
if (mArrayList.get (position).equals (mContext.getString (R.string.add_section_str))) {
drawerItemIcon.setImageResource (R.drawable.ic_add_circle_outline_black_24dp);
}
ListView listView = (ListView) parent;
if (position == listView.getCheckedItemPosition () - 1) { // - 1 for header adjustment
view.setBackgroundResource (R.color.highlight_grey);
drawerItemIcon.setColorFilter (mContext.getResources ().getColor (R.color.accentColor));
subjectName.setTextColor (mContext.getResources ().getColor (R.color.accentColor));
if (DEBUG) Log.d (TAG, "getView: pos = " + position);
}
Log.d (TAG, "getView: view.getParent() = " + view.getParent () + " parent = " + parent);
}
return view;
}
示例2: clearCheckedItem
import android.widget.ListView; //導入方法依賴的package包/類
public void clearCheckedItem() {
ListView lv = getListView();
int checkPosition = lv.getCheckedItemPosition();
if (checkPosition != ListView.INVALID_POSITION) {
lv.setItemChecked(checkPosition,false);
}
mSelectedItemId = 0;
}
示例3: onVisibilityChanged
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onVisibilityChanged(boolean visible) {
if(visible) {
attachAdapter();
// Start loading
if(!alreadyLoaded) {
getLoaderManager().initLoader(0, null, this);
alreadyLoaded = true;
}
}
if (visible && isResumed()) {
ListView lv = getListView();
if (lv != null && mAdapter != null) {
final int checkedPos = lv.getCheckedItemPosition();
if (checkedPos >= 0) {
// TODO post instead
Thread t = new Thread() {
public void run() {
Cursor c = (Cursor) mAdapter.getItem(checkedPos - getListView().getHeaderViewsCount());
if(c != null) {
String from = c.getString(c.getColumnIndex(SipMessage.FIELD_FROM));
String to = c.getString(c.getColumnIndex(SipMessage.FIELD_TO));
final String fromFull = c.getString(c.getColumnIndex(SipMessage.FIELD_FROM_FULL));
String number = from;
if (SipMessage.SELF.equals(number)) {
number = to;
}
final String nbr = number;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
viewDetails(checkedPos, nbr, fromFull);
}
});
}
};
};
t.start();
}
}
}
}
示例4: onVisibilityChanged
import android.widget.ListView; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onVisibilityChanged(boolean visible) {
if (mShowOptionsMenu != visible) {
mShowOptionsMenu = visible;
// Invalidate the options menu since we are changing the list of
// options shown in it.
SherlockFragmentActivity activity = getSherlockActivity();
if (activity != null) {
activity.invalidateOptionsMenu();
}
}
if(visible) {
attachAdapter();
// Start loading
if(!alreadyLoaded) {
getLoaderManager().initLoader(0, null, this);
alreadyLoaded = true;
}
}
if (visible && isResumed()) {
//getLoaderManager().restartLoader(0, null, this);
ListView lv = getListView();
if (lv != null && mAdapter != null) {
final int checkedPos = lv.getCheckedItemPosition();
if (checkedPos >= 0) {
// TODO post instead
Thread t = new Thread() {
public void run() {
final long[] selectedIds = mAdapter.getCallIdsAtPosition(checkedPos);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
viewDetails(checkedPos, selectedIds);
}
});
};
};
t.start();
}
}
}
if(!visible && mMode != null) {
mMode.finish();
}
}