Java Code Examples for android.widget.ListView#setMultiChoiceModeListener()

The following examples show how to use android.widget.ListView#setMultiChoiceModeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListFragment.java    From holoaccent with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View result = inflater.inflate(R.layout.list, null);
	
	mListView = (ListView)result.findViewById(R.id.listView);
	mAdapter = new ArrayAdapter<String>(getActivity(), 
			R.layout.list_item_multiple_choice,
			android.R.id.text1,
			getResources().getStringArray(R.array.list_items));
	mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
	mListView.setAdapter(mAdapter);
	mListView.setOnItemClickListener(this);
	mListView.setMultiChoiceModeListener(mMultiChoiceModeListener);
	mListView.setFastScrollEnabled(true);
	mListView.setFastScrollAlwaysVisible(true);
	
	setHasOptionsMenu(true);
	
	return result;
}
 
Example 2
Source File: History.java    From NoiseCapture with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.measurementManager = new MeasurementManager(getApplicationContext());
    setContentView(R.layout.activity_history);
    initDrawer();

    // Fill the listview
    historyListAdapter = new InformationHistoryAdapter(measurementManager, this);
    infohistory = (ListView)findViewById(R.id.listiew_history);
    infohistory.setMultiChoiceModeListener(new HistoryMultiChoiceListener(this));
    infohistory.setAdapter(historyListAdapter);
    infohistory.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    infohistory.setLongClickable(true);
    infohistory.setOnItemClickListener(new HistoryItemListener(this));
}
 
Example 3
Source File: NotesFragment.java    From writeily-pro with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = getActivity().getApplicationContext();
    layoutView = inflater.inflate(R.layout.notes_fragment, container, false);
    hintTextView = (TextView) layoutView.findViewById(R.id.empty_hint);
    filesListView = (ListView) layoutView.findViewById(R.id.notes_listview);

    filesAdapter = new NotesAdapter(context, 0, filesCurrentlyShown);
    simpleSectionAdapter =
            new SimpleSectionAdapter<> (context, filesAdapter, R.layout.notes_fragment_section_header, R.id.notes_fragment_section_text, sectionizer);

    filesListView.setOnItemClickListener(new NotesItemClickListener());
    filesListView.setMultiChoiceModeListener(new ActionModeCallback());
    filesListView.setAdapter(simpleSectionAdapter);
    rootDir = getRootFolderFromPrefsOrDefault();

    return layoutView;
}
 
Example 4
Source File: EditTemplateActivity.java    From SmileEssence with MIT License 5 votes vote down vote up
private void initializeViews() {
    ListView listView = getListView();
    adapter = new CustomListAdapter<>(this, Template.class);
    listView.setAdapter(adapter);
    adapter.addToTop(getTemplates());
    adapter.update();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setOnItemClickListener(this);
    listView.setMultiChoiceModeListener(this);
}
 
Example 5
Source File: List15.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    lv.setMultiChoiceModeListener(new ModeCallback());
    setListAdapter(new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_checked, mStrings));
}
 
Example 6
Source File: List16.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ListView lv = getListView();
    lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    lv.setMultiChoiceModeListener(new ModeCallback());
    setListAdapter(new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_activated_1, Cheeses.sCheeseStrings));
}
 
Example 7
Source File: ReviewBootPreferenceFragment.java    From android-kernel-tweaker with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	super.onCreateView(inflater, container, savedInstanceState);
	View v = inflater.inflate(R.layout.layout_list, container,false);

	listView = (ListView) v.findViewById(android.R.id.list);
	listView.setFastScrollEnabled(true);
	listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
	registerForContextMenu(listView);
	listView.setMultiChoiceModeListener(new ListViewMultiChoiceModeListener(
			mContext,getActivity(),
			listView,mRoot,
			mCpu,
			mGpu,
			mUv,
			mKernel,
			mLmk,
			mGov,
			mSched,
			mQuiet,
			mVm,
			db,
			VddDb,
			true));


	return v;
}
 
Example 8
Source File: VM.java    From android-kernel-tweaker with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	super.onCreateView(inflater, container, savedInstanceState);
	View v = inflater.inflate(R.layout.layout_list, container,false);
	ListView listView = (ListView) v.findViewById(android.R.id.list);
	listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
	registerForContextMenu(listView);
	listView.setMultiChoiceModeListener(new ListViewMultiChoiceModeListener(
			context,getActivity(),
			listView,mRootScreen,
			false,
			MainActivity.db,
			MainActivity.vddDb));
	return v;
}
 
Example 9
Source File: ListFragmentManage.java    From rss with GNU General Public License v3.0 5 votes vote down vote up
@Override
public
void onActivityCreated(Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);

    FeedsActivity activity = (FeedsActivity) getActivity();
    ListView listView = getListView();

    setListAdapter(new AdapterManageItems(activity));

    registerForContextMenu(listView);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new MultiModeListenerManage(listView, activity));
}
 
Example 10
Source File: ListFragmentFavourites.java    From rss with GNU General Public License v3.0 5 votes vote down vote up
@Override
public
void onActivityCreated(Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);

    ListView listView = getListView();

    registerForContextMenu(listView);
    listView.post(new LoadFavourites());
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new MultiModeListenerFavourites(listView, getResources()));
}
 
Example 11
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 12
Source File: EditExtractionActivity.java    From SmileEssence with MIT License 5 votes vote down vote up
private void initializeViews() {
    ListView listView = getListView();
    adapter = new CustomListAdapter<>(this, ExtractionWord.class);
    listView.setAdapter(adapter);
    adapter.addToTop(getExtractionWords());
    adapter.update();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setOnItemClickListener(this);
    listView.setMultiChoiceModeListener(this);
}
 
Example 13
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 14
Source File: DirectoryFragment.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 15
Source File: AccountActivity.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {

    // CookieManager manager = CookieManager.getInstance();
    // manager.removeAllCookie();

    String action = getIntent() != null ? getIntent().getAction() : null;

    if (ACTION_OPEN_FROM_APP_INNER.equals(action)) {
        // empty
    } else if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {
        // empty
    } else {
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.accountactivity_layout);


    Toolbar mToolBar = (Toolbar) findViewById(R.id.accountToolBar);
    setSupportActionBar(mToolBar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolBar.setNavigationOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });


    listAdapter = new AccountAdapter();
    listView = (ListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(new AccountListItemClickListener());
    listView.setAdapter(listAdapter);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new AccountMultiChoiceModeListener());
    getLoaderManager().initLoader(LOADER_ID, null, this);

    if (SettingUtils.firstStart()) {
        showChangeLogDialog();
    }

    if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {

        startOAuthActivity(false, null);

        AccountBean accountBean = getIntent().getParcelableExtra(REFRESH_ACTION_EXTRA);

        Toast.makeText(this, String.format(getString(R.string.account_token_has_expired), accountBean.getUsernick()),
                Toast.LENGTH_SHORT).show();

    }

}
 
Example 16
Source File: AccountActivity.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {

    // CookieManager manager = CookieManager.getInstance();
    // manager.removeAllCookie();

    String action = getIntent() != null ? getIntent().getAction() : null;

    if (ACTION_OPEN_FROM_APP_INNER.equals(action)) {
        // empty
    } else if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {
        // empty
    } else {
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.accountactivity_layout);


    Toolbar mToolBar = (Toolbar) findViewById(R.id.accountToolBar);
    setSupportActionBar(mToolBar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolBar.setNavigationOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });


    listAdapter = new AccountAdapter();
    listView = (ListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(new AccountListItemClickListener());
    listView.setAdapter(listAdapter);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new AccountMultiChoiceModeListener());
    getLoaderManager().initLoader(LOADER_ID, null, this);

    if (SettingUtils.firstStart()) {
        showChangeLogDialog();
    }

    if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {

        startOAuthActivity(false, null);

        AccountBean accountBean = getIntent().getParcelableExtra(REFRESH_ACTION_EXTRA);

        Toast.makeText(this, String.format(getString(R.string.account_token_has_expired), accountBean.getUsernick()),
                Toast.LENGTH_SHORT).show();

    }

}
 
Example 17
Source File: DataList.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    Bundle arguments = getArguments();
    double latitude = arguments.getDouble(ARG_LATITUDE);
    double longitude = arguments.getDouble(ARG_LONGITUDE);
    boolean currentLocation = arguments.getBoolean(ARG_CURRENT_LOCATION);
    boolean noExtraSources = arguments.getBoolean(ARG_NO_EXTRA_SOURCES);
    int minHeight = arguments.getInt(ARG_HEIGHT, 0);

    if (savedInstanceState != null) {
        latitude = savedInstanceState.getDouble(ARG_LATITUDE);
        longitude = savedInstanceState.getDouble(ARG_LONGITUDE);
    }

    mCoordinates = new GeoPoint(latitude, longitude);

    if (currentLocation)
        mDataSource.setReferenceLocation(mCoordinates);
    else
        mDataSource.setReferenceLocation(null);

    TextView emptyView = (TextView) getListView().getEmptyView();
    if (emptyView != null) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(getString(R.string.msgEmptyPlaceList));
        if (noExtraSources) {
            stringBuilder.append(mLineSeparator);
            stringBuilder.append(mLineSeparator);
            stringBuilder.append(getString(R.string.msgNoFileDataSources));
        }
        emptyView.setText(stringBuilder.toString());
    }

    mAdapter = new DataListAdapter(getActivity(), mDataSource.getCursor(), 0);
    setListAdapter(mAdapter);

    ListView listView = getListView();
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(mMultiChoiceModeListener);

    View rootView = getView();
    if (rootView != null && minHeight > 0)
        rootView.setMinimumHeight(minHeight);

    // If list contains no data footer is not displayed, so we should not worry about
    // message being shown twice
    if (noExtraSources) {
        LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (inflater != null)
            listView.addFooterView(inflater.inflate(R.layout.list_footer_data_source, listView, false), null, false);
    }

    if (mDataSource instanceof WaypointDbDataSource) {
        mFloatingButton = mFragmentHolder.enableListActionButton();
        mFloatingButton.setImageDrawable(getContext().getDrawable(R.drawable.ic_add_location));
        mFloatingButton.setOnClickListener(v -> {
            CoordinatesInputDialog.Builder builder = new CoordinatesInputDialog.Builder();
            CoordinatesInputDialog coordinatesInput = builder.setCallbacks(DataList.this)
                    .setTitle(getString(R.string.titleCoordinatesInput))
                    .create();
            coordinatesInput.show(getFragmentManager(), "pointCoordinatesInput");
        });
    }
}