Java Code Examples for android.view.View#setSelected()

The following examples show how to use android.view.View#setSelected() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Android   File: MulContactAdapter.java    License: MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    int posi = (int) v.getTag();
    ContactEntity index = friendEntities.get(posi);
    String pubkey = index.getPub_key();
    if (!members.contains(pubkey)) {
        View secview = v.findViewById(R.id.select);
        if (selectEntities.contains(index)) {
            selectEntities.remove(index);
            secview.setSelected(false);
        } else {
            selectEntities.add(index);
            secview.setSelected(true);
        }
    }

    if(onSeleFriendListence != null){
        onSeleFriendListence.seleFriend(selectEntities);
    }

}
 
Example 2
Source Project: Gojuon   File: CharactersFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    try {
        String katakana = mCharactersAdapter.getItem(i)[Characters.INDEX_KATAKANA];

        // Pronounce the character
        Gojuon.pronounce(getActivity(), katakana);

        // Mark as selected.
        if (mSharedPreferences.getBoolean(Gojuon.KEY_HIGHLIGHT_SELECTED, true) && !katakana.isEmpty()) {
            view.setSelected(true);
        }
    } catch (RuntimeException e) {
        e.printStackTrace();
    }
}
 
Example 3
@Override
public void setCurrentItem(int item) {
    if (mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    mSelectedIndex = item;
    mViewPager.setCurrentItem(item);

    int tabCount = mIconsLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        View child = mIconsLayout.getChildAt(i);
        boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToIcon(item);
        }
    }
}
 
Example 4
@Override
public void setCurrentItem(int item) {
    if (mViewPager == null) {
        throw new IllegalStateException("ViewPager has not been bound.");
    }
    mSelectedIndex = item;
    mViewPager.setCurrentItem(item);

    int tabCount = mIconsLayout.getChildCount();
    for (int i = 0; i < tabCount; i++) {
        View child = mIconsLayout.getChildAt(i);
        boolean isSelected = (i == item);
        child.setSelected(isSelected);
        if (isSelected) {
            animateToIcon(item);
        }
    }
}
 
Example 5
Source Project: MeiBaseModule   File: BottomBar.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    SavedState ss = (SavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());
    if (mCurrentPosition != ss.position) {
        View beforeView = mTabLayout.getChildAt(mCurrentPosition);
        if (beforeView != null) {
            beforeView.setSelected(false);
        }
        View currentView = mTabLayout.getChildAt(ss.position);
        if (currentView != null) {
            currentView.setSelected(true);
        }
    }
    mCurrentPosition = ss.position;
}
 
Example 6
Source Project: mOrgAnd   File: FileDialog.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Quando clica no item da lista, deve-se: 1) Se for diretorio, abre seus
 * arquivos filhos; 2) Se puder escolher diretorio, define-o como sendo o
 * path escolhido. 3) Se for arquivo, define-o como path escolhido. 4) Ativa
 * botao de selecao.
 */
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    File file = new File(path.get(position));

    setSelectVisible(v);

    if (file.isDirectory()) {
        selectButton.setEnabled(false);
        if (file.canRead()) {
            lastPositions.put(currentPath, position);
            getDir(path.get(position));
            if (canSelectDir) {
                selectedFile = file;
                v.setSelected(true);
                selectButton.setEnabled(true);
            }
        } else {
            new AlertDialog.Builder(this).setIcon(R.drawable.ic_launcher)
                    .setTitle("[" + file.getName() + "] " + getText(R.string.cant_read_folder))
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    }).show();
        }
    } else {
        selectedFile = file;
        v.setSelected(true);
        selectButton.setEnabled(true);
    }
}
 
Example 7
Source Project: kAndroid   File: KChartTabView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (mSelectedIndex >= 0 && mSelectedIndex < mLlContainer.getChildCount()) {
        mLlContainer.getChildAt(mSelectedIndex).setSelected(false);
    }
    mSelectedIndex = mLlContainer.indexOfChild(v);
    v.setSelected(true);
    mTabSelectListener.onTabSelected(mSelectedIndex);
}
 
Example 8
private void updatePageMode(int pageMode) {
    for (int i = 0; i < pageAnimModeView.getChildCount(); i++) {
        View child = pageAnimModeView.getChildAt(i);
        if (child instanceof AppCompatButton) {
            int pos = Integer.parseInt((String) child.getTag());
            child.setSelected(pageMode == pos);
        }
    }
}
 
Example 9
Source Project: AndroidSweetSheet   File: IndicatorView.java    License: Apache License 2.0 5 votes vote down vote up
private void setSelect(int i) {
    View view = mIndicators.get(i);
    view.setSelected(true);
    if(mPreSelectPosition != -1){
        mIndicators.get(mPreSelectPosition).
        setSelected(false);
    }
    mPreSelectPosition=i;
}
 
Example 10
private void setPageMode(int pageMode) {
    View selectedView = null;
    switch (pageMode) {
        case PageView.PAGE_MODE_COVER:
            readTvFlipOverCover.setSelected(true);
            selectedView = readTvFlipOverCover;
            break;
        case PageView.PAGE_MODE_SIMULATION:
            readTvFlipOverSimulation.setSelected(true);
            selectedView = readTvFlipOverSimulation;
            break;
        case PageView.PAGE_MODE_SLIDE:
            readTvFlipOverSlide.setSelected(true);
            selectedView = readTvFlipOverSlide;
            break;
        case PageView.PAGE_MODE_NONE:
            readTvFlipOverNone.setSelected(true);
            selectedView = readTvFlipOverNone;
            break;
    }
    for (View view : flipOverViews) {
        if (view != selectedView && view.isSelected()) {
            view.setSelected(false);
        }
    }
    if (pageMode != mPageView.getPageMode()) {
        mPageView.setPageAnimMode(pageMode);
        ReaderSettingManager
                .getInstance()
                .setPageMode(pageMode);
    }

}
 
Example 11
/**
 * Called when a selected tab is added. Unselects all other tabs in the TabLayout.
 *
 * @param position Position of the selected tab.
 */
private void setSelectedTabView(int position) {
  final int tabCount = slidingTabIndicator.getChildCount();
  if (position < tabCount) {
    for (int i = 0; i < tabCount; i++) {
      final View child = slidingTabIndicator.getChildAt(i);
      child.setSelected(i == position);
      child.setActivated(i == position);
    }
  }
}
 
Example 12
public void addTab(CharSequence label, int contentViewId) {
    View tabView = LayoutInflater.from(mContext).inflate(R.layout.tab, mTabContainer, false);
    ((TextView) tabView.findViewById(R.id.tab)).setText(label);
    tabView.setOnClickListener(mTabClickListener);
    int position = mTabContentIds.size();
    tabView.setSelected(mPager.getCurrentItem() == position);
    mTabPositions.put(tabView, position);
    mTabContainer.addView(tabView);
    mTabContentIds.add(contentViewId);
}
 
Example 13
@Override
public View create(Context context, View convertView, ViewGroup parent,
        LayoutInflater inflater) {
    View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false);

    int selectedIndex = ringerModeToIndex(mAudioManager.getRingerMode());
    for (int i = 0; i < 3; i++) {
        View itemView = v.findViewById(ITEM_IDS[i]);
        itemView.setSelected(selectedIndex == i);
        // Set up click handler
        itemView.setTag(i);
        itemView.setOnClickListener(this);
    }
    return v;
}
 
Example 14
public void redrawTabs(int currentPosition) {
    try {
        for (int i = 0; i < tabsContainer.getChildCount(); ++i) {
            View tmp = tabsContainer.getChildAt(i);
            if (i == currentPosition) {
                tmp.setSelected(true);
            } else {
                tmp.setSelected(false);
            }
        }
    } catch (Exception e) {
        //no-op
    }
}
 
Example 15
Source Project: letv   File: HListView.java    License: Apache License 2.0 5 votes vote down vote up
private void handleNewSelectionChange(View selectedView, int direction, int newSelectedPosition, boolean newFocusAssigned) {
    if (newSelectedPosition == -1) {
        throw new IllegalArgumentException("newSelectedPosition needs to be valid");
    }
    int leftViewIndex;
    int rightViewIndex;
    View leftView;
    View rightView;
    boolean leftSelected = false;
    int selectedIndex = this.mSelectedPosition - this.mFirstPosition;
    int nextSelectedIndex = newSelectedPosition - this.mFirstPosition;
    if (direction == 33) {
        leftViewIndex = nextSelectedIndex;
        rightViewIndex = selectedIndex;
        leftView = getChildAt(leftViewIndex);
        rightView = selectedView;
        leftSelected = true;
    } else {
        leftViewIndex = selectedIndex;
        rightViewIndex = nextSelectedIndex;
        leftView = selectedView;
        rightView = getChildAt(rightViewIndex);
    }
    int numChildren = getChildCount();
    if (leftView != null) {
        boolean z = !newFocusAssigned && leftSelected;
        leftView.setSelected(z);
        measureAndAdjustRight(leftView, leftViewIndex, numChildren);
    }
    if (rightView != null) {
        z = (newFocusAssigned || leftSelected) ? false : true;
        rightView.setSelected(z);
        measureAndAdjustRight(rightView, rightViewIndex, numChildren);
    }
}
 
Example 16
Source Project: KChartView   File: KChartTabView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    if (mSelectedIndex >= 0 && mSelectedIndex < mLlContainer.getChildCount()) {
        mLlContainer.getChildAt(mSelectedIndex).setSelected(false);
    }
    mSelectedIndex = mLlContainer.indexOfChild(v);
    v.setSelected(true);
    mTabSelectListener.onTabSelected(mSelectedIndex);
}
 
Example 17
@Thunk void selectTile(View v) {
    if (mSelectedTile != null) {
        mSelectedTile.setSelected(false);
        mSelectedTile = null;
    }
    mSelectedTile = v;
    v.setSelected(true);
    mSelectedIndex = mWallpapersView.indexOfChild(v);
    // TODO: Remove this once the accessibility framework and
    // services have better support for selection state.
    v.announceForAccessibility(
            getContext().getString(R.string.announce_selection, v.getContentDescription()));
}
 
Example 18
Source Project: SelectorDrawable   File: MainActivity.java    License: Apache License 2.0 4 votes vote down vote up
public void onClick(View view) {
    view.setSelected(!view.isSelected());
}
 
Example 19
@Override
public void tabSelected(View view) {
    view.setSelected(true);
}
 
Example 20
Source Project: AndroidStarterKit   File: SlidingTabLayout.java    License: MIT License 4 votes vote down vote up
private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        View tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        if (TextView.class.isInstance(tabTitleView)) {
            ((TextView) tabTitleView).setText(adapter.getPageTitle(i));
        } else if (ImageView.class.isInstance(tabTitleView) && adapter instanceof TabIconProvider){
            TabIconProvider mTabIconProvider = (TabIconProvider) adapter;
            tabTitleView.setBackgroundResource(mTabIconProvider.getPageIconResId(i));
        }

        tabView.setOnClickListener(tabClickListener);

        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
    }
}