Java Code Examples for android.widget.ListView.setItemChecked()

The following are Jave code examples for showing how to use setItemChecked() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: TimeTrix   File: NavigationDrawerFragment.java   View Source Code Vote up 6 votes
@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;
}
 
Example 2
Project: CodeCompilerApp   File: ThemeDialog.java   View Source Code Vote up 6 votes
@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();
}
 
Example 3
Project: EsperantoRadio   File: Venstremenu_frag.java   View Source Code Vote up 6 votes
@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;
}
 
Example 4
Project: CSipSimple   File: AccountsEditListFragment.java   View Source Code Vote up 5 votes
@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)));
}
 
Example 5
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 5 votes
@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);
    }
}
 
Example 6
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 7
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 5 votes
private void actionModeInvertSelection() {
    ListView lv = getListView();

    for(int i = 0; i < lv.getCount(); i++) {
        lv.setItemChecked(i, !lv.isItemChecked(i));
    }
    mMode.invalidate();
}
 
Example 8
Project: CSipSimple   File: AccountFiltersListFragment.java   View Source Code Vote up 5 votes
@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);
}
 
Example 9
Project: aos-Video   File: BrowserCategory.java   View Source Code Vote up 5 votes
public void clearCheckedItem() {
    ListView lv = getListView();
    int checkPosition = lv.getCheckedItemPosition();
    if (checkPosition != ListView.INVALID_POSITION) {
        lv.setItemChecked(checkPosition,false);
    }
    mSelectedItemId = 0;
}
 
Example 10
Project: buildAPKsSamples   File: TitlesFragment.java   View Source Code Vote up 5 votes
/** 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);
}
 
Example 11
Project: CodeCompilerApp   File: EncodingDialog.java   View Source Code Vote up 5 votes
@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();
}