本文整理匯總了Java中android.widget.ListView.setItemChecked方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setItemChecked方法的具體用法?Java ListView.setItemChecked怎麽用?Java ListView.setItemChecked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListView
的用法示例。
在下文中一共展示了ListView.setItemChecked方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mDrawerListView = (ListView) inflater.inflate (
R.layout.fragment_navigation_drawer, container, false);
arrayList = new ArrayList<> ();
DatabaseAdapter databaseAdapter = new DatabaseAdapter (getActivity (), null);
arrayList = databaseAdapter.getAllSectionNames ();
arrayList.add (getString (R.string.add_section_str));
customAdapter = new CustomAdapter (arrayList, getActivity (), "navigation_drawer", null);
mDrawerListView.setAdapter (customAdapter);
mSharedPrefsUtil = new SharedPrefsUtil (getActivity ());
updateHeaderView (mSharedPrefsUtil.getUserEmail (), mSharedPrefsUtil.getUserName ());
mDrawerListView.setOnItemClickListener (new AdapterView.OnItemClickListener () {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (DEBUG) Log.d (TAG, "onCreateView: currentPos = " + position);
selectItemWithCallback (position);
}
});
mDrawerListView.setItemChecked (mCurrentSelectedPosition, true);
return mDrawerListView;
}
示例2: onCreateDialog
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_theme_list, null);
list = (ListView) view.findViewById(android.R.id.list);
String[] themes = {
getString(R.string.theme_dark), getString(R.string.light_theme), getString(R.string.theme_black)
};
list.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.item_single_choice, themes));
list.setOnItemClickListener(this);
int currentTheme = PreferenceHelper.getTheme(getActivity());
for (int i = 0; i < themes.length; i++) {
if (i == currentTheme)
list.setItemChecked(i, true);
}
return new AlertDialog.Builder(getActivity())
.setView(view)
.create();
}
示例3: onCreateView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
listView = (ListView) inflater.inflate(R.layout.venstremenu_frag, container, false);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
venstremenuAdapter.vælgMenu(getActivity(), position);
}
});
venstremenuAdapter = new VenstremenuAdapter(getActivity());
listView.setAdapter(venstremenuAdapter);
listView.setItemChecked(mCurrentSelectedPosition, true);
for (Backend b : App.backend) b.favoritter.observatører.add(this);
App.data.hentedeUdsendelser.observatører.add(this);
Alarms.setNextAlert(getActivity());
return listView;
}
示例4: onListItemClick
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.d(THIS_FILE, "Checked " + position + " et " + id);
ListView lv = getListView();
lv.setItemChecked(position, true);
curCheckPosition = id;
Cursor c = (Cursor) getListAdapter().getItem(position - lv.getHeaderViewsCount());
showDetails(id, c.getString(c.getColumnIndex(SipProfile.FIELD_WIZARD)));
}
示例5: viewDetails
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void viewDetails(int position, long[] callIds) {
ListView lv = getListView();
if(mMode != null) {
lv.setItemChecked(position, !lv.isItemChecked(position));
mMode.invalidate();
// Don't see details in this case
return;
}
if (mDualPane) {
// If we are not currently showing a fragment for the new
// position, we need to create and install a new one.
CallLogDetailsFragment df = new CallLogDetailsFragment();
Bundle bundle = new Bundle();
bundle.putLongArray(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds);
df.setArguments(bundle);
// Execute a transaction, replacing any existing fragment
// with this one inside the frame.
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.details, df, null);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
getListView().setItemChecked(position, true);
} else {
Intent it = new Intent(getActivity(), CallLogDetailsActivity.class);
it.putExtra(CallLogDetailsFragment.EXTRA_CALL_LOG_IDS, callIds);
getActivity().startActivity(it);
}
}
示例6: onDestroyActionMode
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onDestroyActionMode(ActionMode mode) {
Log.d(THIS_FILE, "onDestroyActionMode");
ListView lv = getListView();
// Uncheck all
int count = lv.getAdapter().getCount();
for (int i = 0; i < count; i++) {
lv.setItemChecked(i, false);
}
mMode = null;
}
示例7: actionModeInvertSelection
import android.widget.ListView; //導入方法依賴的package包/類
private void actionModeInvertSelection() {
ListView lv = getListView();
for(int i = 0; i < lv.getCount(); i++) {
lv.setItemChecked(i, !lv.isItemChecked(i));
}
mMode.invalidate();
}
示例8: onListItemClick
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Log.d(THIS_FILE, "Checked " + position + " et " + id);
ListView lv = getListView();
lv.setItemChecked(position, true);
curCheckFilterId = id;
showDetails(id);
}
示例9: 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;
}
示例10: selectPosition
import android.widget.ListView; //導入方法依賴的package包/類
/** Called to select an item from the listview */
public void selectPosition(int position) {
// Only if we're showing both fragments should the item be "highlighted"
if (mDualFragments) {
ListView lv = getListView();
lv.setItemChecked(position, true);
}
// Calls the parent activity's implementation of the OnItemSelectedListener
// so the activity can pass the event to the sibling fragment as appropriate
mListener.onItemSelected(mCategory, position);
}
示例11: onCreateDialog
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_encoding_list, null);
list = (ListView) view.findViewById(android.R.id.list);
SwitchCompat autoencoding = (SwitchCompat) view.findViewById(android.R.id.checkbox);
autoencoding.setChecked(PreferenceHelper.getAutoEncoding(getActivity()));
autoencoding.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
PreferenceHelper.setAutoencoding(getActivity(), isChecked);
}
});
list.setAdapter(new ArrayAdapter<>(getActivity(), R.layout.item_single_choice, encodings));
list.setOnItemClickListener(this);
String currentEncoding = PreferenceHelper.getEncoding(getActivity());
for (int i = 0; i < encodings.length; i++) {
if (currentEncoding.equals(encodings[i])) {
list.setItemChecked(i, true);
}
}
return new AlertDialog.Builder(getActivity())
.setView(view)
.create();
}