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

The following are Jave code examples for showing how to use getCheckedItemPosition() 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: CustomAdapter.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, final View convertView, ViewGroup parent) {
    View view = convertView;
    if (mParam.equals ("navigation_drawer")) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate (R.layout.custom_row_nav_item, parent, false);
        TextView subjectName = (TextView) view.findViewById (R.id.textViewRow);
        Typeface typeface = Typeface.createFromAsset (mContext.getAssets (), "font/Roboto_Medium.ttf");
        subjectName.setTypeface (typeface);
        subjectName.setText (mArrayList.get (position));
        ImageView drawerItemIcon = (ImageView) view.findViewById (R.id.listIcon);
        if (mArrayList.get (position).equals (mContext.getString (R.string.add_section_str))) {
            drawerItemIcon.setImageResource (R.drawable.ic_add_circle_outline_black_24dp);
        }
        ListView listView = (ListView) parent;
        if (position == listView.getCheckedItemPosition () - 1) {  // - 1 for header adjustment
            view.setBackgroundResource (R.color.highlight_grey);
            drawerItemIcon.setColorFilter (mContext.getResources ().getColor (R.color.accentColor));
            subjectName.setTextColor (mContext.getResources ().getColor (R.color.accentColor));
            if (DEBUG) Log.d (TAG, "getView: pos = " + position);
        }
        Log.d (TAG, "getView: view.getParent() = " + view.getParent () + " parent = " + parent);
    }
    return view;
}
 
Example 2
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 3
Project: CSipSimple   File: ConversationsListFragment.java   View Source Code Vote up 4 votes
@Override
public void onVisibilityChanged(boolean visible) {

    if(visible) {
        attachAdapter();
        // Start loading
        if(!alreadyLoaded) {
            getLoaderManager().initLoader(0, null, this);
            alreadyLoaded = true;
        }
    }
    
    if (visible && isResumed()) {
        ListView lv = getListView();
        if (lv != null && mAdapter != null) {
            final int checkedPos = lv.getCheckedItemPosition();
            if (checkedPos >= 0) {
                // TODO post instead
                Thread t = new Thread() {
                    public void run() {
                        Cursor c = (Cursor) mAdapter.getItem(checkedPos - getListView().getHeaderViewsCount());
                        if(c != null) {
                            String from = c.getString(c.getColumnIndex(SipMessage.FIELD_FROM));
                            String to = c.getString(c.getColumnIndex(SipMessage.FIELD_TO));
                            final String fromFull = c.getString(c.getColumnIndex(SipMessage.FIELD_FROM_FULL));
                            String number = from;
                            if (SipMessage.SELF.equals(number)) {
                                number = to;
                            }
                            final String nbr = number;
                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    viewDetails(checkedPos, nbr, fromFull);
                                }
                            });
                        }
                    };
                };
                t.start();
            }
        }
    }
}
 
Example 4
Project: CSipSimple   File: CallLogListFragment.java   View Source Code Vote up 4 votes
@SuppressLint("NewApi")
@Override
public void onVisibilityChanged(boolean visible) {
    if (mShowOptionsMenu != visible) {
        mShowOptionsMenu = visible;
        // Invalidate the options menu since we are changing the list of
        // options shown in it.
        SherlockFragmentActivity activity = getSherlockActivity();
        if (activity != null) {
            activity.invalidateOptionsMenu();
        }
    }
    

    if(visible) {
        attachAdapter();
        // Start loading
        if(!alreadyLoaded) {
            getLoaderManager().initLoader(0, null, this);
            alreadyLoaded = true;
        }
    }
    
    
    if (visible && isResumed()) {
        //getLoaderManager().restartLoader(0, null, this);
        ListView lv = getListView();
        if (lv != null && mAdapter != null) {
            final int checkedPos = lv.getCheckedItemPosition();
            if (checkedPos >= 0) {
                // TODO post instead
                Thread t = new Thread() {
                    public void run() {
                        final long[] selectedIds = mAdapter.getCallIdsAtPosition(checkedPos);
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                viewDetails(checkedPos, selectedIds);  
                            }
                        });
                    };
                };
                t.start();
            }
        }
    }
    
    
    if(!visible && mMode != null) {
        mMode.finish();
    }
}