当前位置: 首页>>代码示例>>Java>>正文


Java ListView.setItemChecked方法代码示例

本文整理汇总了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;
}
 
开发者ID:atulgpt,项目名称:TimeTrix,代码行数:24,代码来源:NavigationDrawerFragment.java

示例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();
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:25,代码来源:ThemeDialog.java

示例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;
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:18,代码来源:Venstremenu_frag.java

示例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)));
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:13,代码来源:AccountsEditListFragment.java

示例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);
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:32,代码来源:CallLogListFragment.java

示例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;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:13,代码来源:CallLogListFragment.java

示例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();
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:9,代码来源:CallLogListFragment.java

示例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);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:12,代码来源:AccountFiltersListFragment.java

示例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;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:9,代码来源:BrowserCategory.java

示例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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:12,代码来源:TitlesFragment.java

示例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();
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:32,代码来源:EncodingDialog.java


注:本文中的android.widget.ListView.setItemChecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。