本文整理汇总了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();
}
}