Example usage for android.widget AbsListView CHOICE_MODE_NONE

List of usage examples for android.widget AbsListView CHOICE_MODE_NONE

Introduction

In this page you can find the example usage for android.widget AbsListView CHOICE_MODE_NONE.

Prototype

int CHOICE_MODE_NONE

To view the source code for android.widget AbsListView CHOICE_MODE_NONE.

Click Source Link

Document

Normal list that does not indicate choices

Usage

From source file:com.chrismorais.android.sunshine.app.ForecastFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
    mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
    mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
    a.recycle();//from   w w  w  .  jav  a  2s.  c om
}

From source file:org.mapsforge.applications.android.ItemListFragment.java

/**
 * Turns on activate-on-click mode. When this mode is on, list items will be
 * given the 'activated' state when touched.
 *///from  ww w.  j a va  2s. co  m
public void setActivateOnItemClick(boolean activateOnItemClick) {
    // When setting CHOICE_MODE_SINGLE, ListView will automatically
    // give items the 'activated' state when touched.
    getListView()
            .setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE);
}

From source file:org.getlantern.firetweet.fragment.CustomTabsFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mPreferences = SharedPreferencesWrapper.getInstance(getActivity(), SHARED_PREFERENCES_NAME,
            Context.MODE_PRIVATE);
    setHasOptionsMenu(true);/*from ww  w .  j a v  a  2 s . c o  m*/
    mResolver = getContentResolver();
    final View view = getView();
    if (view == null)
        throw new AssertionError();
    final Context context = view.getContext();
    mAdapter = new CustomTabsAdapter(context);
    mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mListView.setMultiChoiceModeListener(this);
    mListView.setOnItemClickListener(this);
    mListView.setAdapter(mAdapter);
    mListView.setEmptyView(mEmptyView);
    mListView.setDropListener(new DropListener() {
        @Override
        public void drop(final int from, final int to) {
            mAdapter.drop(from, to);
            if (mListView.getChoiceMode() != AbsListView.CHOICE_MODE_NONE) {
                mListView.moveCheckState(from, to);
            }
            saveTabPositions();
        }
    });
    mEmptyText.setText(R.string.no_tab);
    mEmptyIcon.setImageResource(R.drawable.ic_info_tab);
    getLoaderManager().initLoader(0, null, this);
    setListShown(false);
}

From source file:org.jorge.lolin1.ui.activities.ChatRoomActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar = getActionBar();
    friendName = null;/* w  w  w.  j a  va 2s  .  c  o m*/
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE);
        actionBar.setTitle(friendName = getIntent().getStringExtra(ChatOverviewActivity.KEY_FRIEND_NAME));
        try {
            actionBar
                    .setLogo(
                            Drawable.createFromPath(
                                    ProfileCacheableBitmapLoader
                                            .getPathByID(getApplicationContext(),
                                                    FriendManager.getInstance().findFriendByName(friendName)
                                                            .getStatus().getProfileIconId())
                                            .getAbsolutePath()));
        } catch (NullPointerException ex) {
            startActivity(new Intent(getApplicationContext(), ChatOverviewActivity.class));//Clicking notification with app closed
            finish();
            return;
        }
        actionBar.setDisplayUseLogoEnabled(Boolean.TRUE);
    }
    ChatNotificationManager.dismissNotifications(getApplicationContext(), friendName);
    setContentView(R.layout.activity_chat_room);

    final EditText messageContentsTextField = (EditText) findViewById(android.R.id.inputArea);

    messageContentsTextField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId != EditorInfo.IME_ACTION_DONE)
                return Boolean.FALSE;
            String contents = messageContentsTextField.getText().toString();
            if (TextUtils.isEmpty(contents))
                return Boolean.TRUE;
            adapter.add(new ChatMessageWrapper(contents, System.currentTimeMillis()));
            sendMessage(contents, friendName);
            messageContentsTextField.setText("");
            messageContentsTextField.requestFocus();
            return Boolean.TRUE;
        }

        private void sendMessage(String contents, String friendName) {
            new AsyncTask<String, Void, Void>() {
                @Override
                protected Void doInBackground(String... params) {
                    Friend target;
                    ChatMessageWrapper messageWrapper = new ChatMessageWrapper(params[0],
                            System.currentTimeMillis());
                    logString("debug", "Sending message " + params[0] + " to " + params[1]);
                    ChatBundleManager.addMessageToFriendChat(messageWrapper,
                            target = FriendManager.getInstance().findFriendByName(params[1]));
                    scrollListViewToBottom();
                    target.sendMessage(params[0]);
                    return null;
                }
            }.executeOnExecutor(Executors.newSingleThreadExecutor(), contents, friendName);
        }
    });

    conversationListView = (ListView) findViewById(android.R.id.list);
    conversationListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);

    logString("debug", "Calling adapter constructor");
    adapter = new ChatRoomAdapter(getApplicationContext(),
            FriendManager.getInstance().findFriendByName(friendName));

    if (!TextUtils.isEmpty(friendName))
        conversationListView.setAdapter(adapter);

    scrollListViewToBottom();

    registerLocalBroadcastReceiver();
    scrollListViewToBottom();
}

From source file:com.ant.sunshine.app.fragments.ForecastFragment.java

@Override
public void onInflate(Context activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
    mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
    mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
    mHoldForTransition = a.getBoolean(R.styleable.ForecastFragment_sharedElementTransitions, false);
    a.recycle();//w  ww .  j a  va 2s.c  o  m
}

From source file:com.alboteanu.android.sunshine.app.ForecastFragment.java

@Override
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(activity, attrs, savedInstanceState);
    TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0);
    mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE);
    mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false);
    mHoldForTransition = a.getBoolean(R.styleable.ForecastFragment_sharedElementTransitions, false);
    a.recycle();/*  w w w . j  a  v a2 s  .c om*/
}

From source file:com.shafiq.mytwittle.view.DirectMessageFeedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    mContentHandle = TwitterManager.get().getContentHandle(getContentHandleBase(), getScreenName(),
            getLaneIdentifier(), getApp().getCurrentAccountKey());
    mDirectMessagesHandle = new TwitterDirectMessagesHandle(
            getBaseLaneActivity().getApp().getCurrentAccount().getId(), getOtherUserId());

    if (mContentHandle == null) {
        // Occurs when coming back after the app was sleeping. Force refresh
        // of the adapter in this instance to ensure Fragments are created
        // correctly.
        showToast("No Content Handle found, forcing refresh");
        Intent intent = new Intent("" + SystemEvent.FORCE_FRAGMENT_PAGER_ADAPTER_REFRESH);
        LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(intent);
        return null;
    }/*from  w w  w  .  j  a v a 2  s. com*/

    //
    //
    //
    View resultView = inflater.inflate(R.layout.lane, null);
    configureLaneWidth(resultView);

    mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher);
    mConversationListAdapter = new DirectMessageConversationListAdapter(inflater);
    // mMultipleConversationSelectionCallback = new
    // MultipleConversationSelectionCallback();
    mConversationListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview);
    mConversationListView.getRefreshableView().setOnItemClickListener(mTweetFeedOnItemClickListener);
    mConversationListView.getRefreshableView().setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    // mConversationListView.getRefreshableView().setMultiChoiceModeListener(mMultipleConversationSelectionCallback);
    // mConversationListView.getRefreshableView()
    mConversationListView.getRefreshableView().setOnScrollListener(mOnScrollListener);
    mConversationListView.getRefreshableView().setAdapter(mConversationListAdapter);
    mConversationListView.setOnRefreshListener(mOnRefreshListener);
    mConversationListView.setOnLastItemVisibleListener(mOnLastItemVisibleListener);

    //
    //
    //
    TwitterDirectMessages cachedDirectMessages = TwitterManager.get().getDirectMessages(mContentHandle);
    if (cachedDirectMessages != null) {
        setDirectMessages(cachedDirectMessages);
    } else {
        setDirectMessages(null);
    }

    if (mDirectMessageConversation == null || mDirectMessageConversation.size() == 0) {
        updateViewVisibility(false);
        setInitialDownloadState(InitialDownloadState.WAITING);
    } else {
        setInitialDownloadState(InitialDownloadState.DOWNLOADED);
        updateViewVisibility(true);
    }

    return resultView;
}

From source file:com.github.jvanhie.discogsscrobbler.RecentlyPlayedFragment.java

/**
 * Turns on activate-on-click mode. When this mode is on, list items will be
 * given the 'activated' state when touched.
 *///from ww w  .  j  a v a2  s.co  m
public void setActivateOnItemClick(boolean activateOnItemClick) {
    // When setting CHOICE_MODE_SINGLE, ListView will automatically
    // give items the 'activated' state when touched.
    mList.setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE);
}

From source file:us.rader.tapset.ItemListFragment.java

/**
 * @param activateOnItemClick//w w w  .j a v  a  2  s . c  om
 *            value indicating whether or not an item should be activated
 *            automatically when it is clicked Turns on activate-on-click
 *            mode. When this mode is on, list items will be given the
 *            'activated' state when touched.
 */
public void setActivateOnItemClick(boolean activateOnItemClick) {

    // When setting CHOICE_MODE_SINGLE, ListView will automatically
    // give items the 'activated' state when touched.
    getListView()
            .setChoiceMode(activateOnItemClick ? AbsListView.CHOICE_MODE_SINGLE : AbsListView.CHOICE_MODE_NONE);

}

From source file:tw.idv.palatis.danboorugallery.PostListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // enable progress icon
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminate(true);/*www  .j a v a  2 s.c o m*/

    setContentView(R.layout.activity_post_list);

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // setup drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLeft = (RelativeLayout) findViewById(R.id.left_drawer);
    mDrawerRight = (RelativeLayout) findViewById(R.id.right_drawer);
    ListView hostsList = (ListView) findViewById(R.id.host_list);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerStateChanged(int newState) {
            super.onDrawerStateChanged(newState);

            if (newState == DrawerLayout.STATE_DRAGGING)
                mUiHider.show();
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
        }

        public void onDrawerClosed(View view) {
            if (!mIsDoingSearch && !mDrawerLayout.isDrawerVisible(mDrawerLeft)
                    && !mDrawerLayout.isDrawerVisible(mDrawerRight)) {
                mUiHider.setAutoHideDelay(AUTO_HIDE_DELAY_MILLIS);
                mUiHider.hide();
            }
        }

        public void onDrawerOpened(View drawerView) {
            mUiHider.setAutoHideDelay(UiHider.AUTO_HIDE_DELAY_DISABLED);
            mUiHider.show();
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    HostsTable.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();
            getLoaderManager().restartLoader(R.id.loader_host_ids, null, PostListActivity.this);
        }

        @Override
        public void onInvalidated() {
            super.onInvalidated();
            mHostsAdapter.swapCursor(null);
        }
    });
    mHostsAdapter = new CursorAdapter(this, null, false) {
        private CompoundButton.OnCheckedChangeListener mOnCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton button, boolean checked) {
                ViewHolder holder = (ViewHolder) button.getTag(R.id.view_tag_view_holder);
                Host host = SiteSession.getHostById(holder.host_id);
                host.enabled = checked;
                HostsTable.addOrUpdateHost(host);
            }
        };

        class ViewHolder {
            int host_id;
            TextView title;
            TextView summary;
            CheckBox toggle;

            public ViewHolder(View view, int host_id) {
                this.host_id = host_id;
                this.title = (TextView) view.findViewById(android.R.id.title);
                this.summary = (TextView) view.findViewById(android.R.id.summary);
                this.toggle = (CheckBox) view.findViewById(android.R.id.toggle);
                this.toggle.setTag(R.id.view_tag_view_holder, this);
            }
        }

        @Override
        public View newView(Context context, Cursor cursor, ViewGroup parent) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
            View view = inflater.inflate(R.layout.listitem_drawer_host_item, parent, false);
            view.setTag(R.id.view_tag_view_holder,
                    new ViewHolder(view, cursor.getInt(HostsTable.INDEX_HOST_DATABASE_ID)));
            return view;
        }

        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            Host host = SiteSession.getHostById(cursor.getInt(HostsTable.INDEX_HOST_DATABASE_ID));
            if (host == null)
                return;

            ViewHolder holder = (ViewHolder) view.getTag(R.id.view_tag_view_holder);

            holder.host_id = host.id;
            holder.toggle.setChecked(host.enabled);
            holder.title.setText(host.name);
            holder.summary.setText(host.url);
            holder.toggle.setOnCheckedChangeListener(mOnCheckedChangeListener);
        }
    };
    DrawerListAdapter adapter = new DrawerListAdapter(this, mHostsAdapter);
    hostsList.setAdapter(adapter);
    hostsList.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
    hostsList.setOnItemClickListener(this);
    hostsList.setOnItemLongClickListener(this);

    getLoaderManager().initLoader(R.id.loader_host_ids, null, this);

    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mUiHider = new UiHider(AUTO_HIDE_DELAY_MILLIS, new UiHider.OnVisibilityChangeListener() {
        @Override
        public void onVisibilityChange(boolean visible) {
            if (visible)
                getActionBar().show();
            else
                getActionBar().hide();
        }
    });

    if (savedInstanceState == null) {
        mPostListFragment = new PostListFragment();
        getFragmentManager().beginTransaction().replace(R.id.post_list_container, mPostListFragment).commit();
    }
}