I was checking out your application from you Website, that looks
pretty nice.
On Jul 4, 1:10 pm, Brad Gies <rbg...@gmail.com> wrote:
> You can setup your listener when you are filling in the text
> information... just make it the same listener for all of them, and sort
> out which one it is in the listener event... I usually just use the
> convertView Tag property for that, and set it to the position in your
> Array list.. that way you don't have search through the Array list...
> you can just get the correct item directly.
>
> You probably also want to check the convertView to see if there is
> already a listener on that view, and only set it if there isn't.. Or
> just setup the listener when you inflate the view... I usually check the
> displayed items in the onResume event to make they have the listener
> set, just to be sure... although most of the time it is a redundant check.
>
> On 04/07/2010 9:14 AM, SirAndroidDev wrote:
>
>
>
> > Okay, thanks Brad. I thought the CheckedTextViews (ctv) were all one
> > in the same? Seems I read a post a bit ago that recommeneded casting
> > the second argument in the onListItemClick() method (View v) to get at
> > the actual CheckedTextView. Does that sound right? Sorry I'm a bit
> > in the fog on that part. As the first "ctv" instance in the ListView
> > behaves fine. It's the rest that do not.
>
> > Thanks again for your help today.
>
> > On Jul 4, 11:25 am, Brad Gies<rbg...@gmail.com> wrote:
>
> >> Put a listener on your checkboxes and update your array from there...
> >> Then, you only need to check your array, which is much faster and easier
> >> to handle anyway.
>
> >> On 04/07/2010 8:20 AM, SirAndroidDev wrote:
>
> >>> Thanks. I finally got this going. However, I may not be handling
> >>> this situation the best way.
>
> >>> Now I've been struggling for several more days on another issue.
>
> >>> So, I have a ListView with the following for the row.xml:
>
> >>> <?xml version="1.0" encoding="utf-8"?>
> >>> <com.test.CheckableLinearLayout xmlns:android="http://
> >>> schemas.android.com/apk/res/android"
> >>> android:id="@+id/LinearLayout01"
> >>> android:layout_width="fill_parent"
> >>> android:layout_height="wrap_content">
> >>> <ImageView
> >>> android:src="@drawable/icon"
> >>> android:layout_width="wrap_content"
> >>> android:layout_height="wrap_content"
> >>> android:layout_gravity="center_vertical"
> >>> android:focusable="false"
> >>> android:layout_marginLeft="5dip"/>
> >>> <TextView
> >>> android:id="@+id/filename"
> >>> android:layout_width="wrap_content"
> >>> android:textSize="14sp"
> >>> android:layout_height="wrap_content"
> >>> android:padding="5dip"
> >>> android:textColor="#FFFFFF"
> >>> android:layout_weight="1.0" />
> >>> <TextView
> >>> android:text=""
> >>> android:id="@+id/fileDetails"
> >>> android:textSize="10sp"
> >>> android:textColor="#FFFFFF"
> >>> android:layout_width="wrap_content"
> >>> android:layout_height="wrap_content"
> >>> android:layout_gravity="center" />
> >>> <CheckedTextView
> >>> android:id="@+id/ctv"
> >>> android:layout_width="wrap_content"
> >>> android:layout_height="wrap_content"
> >>> android:layout_marginRight="6dip"
> >>> android:background="#00000000"
> >>> android:focusable="false"
> >>> android:clickable="false"
> >>> android:checked="false"
> >>> android:checkMark="@drawable/checkedstate" />
> >>> </com.test.CheckableLinearLayout>
>
> >>> Now, I can get each item to go into an ArrayList<String> and then I
> >>> perform an operation on that array. Plus, each row in the ListView
> >>> will show my checkbox properly checked and unchecked as the user
> >>> performs clicks on the CheckedTextViews for each row. However, I'm
> >>> now having a problem where I cannot get a list of currently checked
> >>> (read: clicked on) items. I found getCheckedItemPositions() and
> >>> getCheckItemIds(), but I was not able to get them to handle what I
> >>> need, that is to see what checkboxes are NOT checked.
>
> >>> Example, a user clicks on three checkboxes (read: 3 rows), showing he/
> >>> she wants to do something with three selected files in the
> >>> ListView.... so far so good. Now, the user UNCHECKS (or un-selects if
> >>> you like) one of the checkboxes. I try to check (if()) to see which
> >>> checkbox was unchecked but when I try to test against the ctv (name of
> >>> my CheckedTextView), no go. That only works for the first row in the
> >>> ListView, it's fails for all of the rest of the rows. so I can
> >>> uncheck the first row, check it, unchecked and all that works fine,
> >>> just not when I do that on any other row (read: checkbox).
>
> >>> There has got to be a simple way to test for checked and unchecked
> >>> CheckedTextViews in a ListView? If so, can you push me in the right
> >>> direction Mickey (or someone)?
>
> >>> Here is where I'm at (in the middle of a testing what ever I could to
> >>> get this going so the code is sloppy and I left off the "else" clause
> >>> part for the overall conditional. (the multiselect is for a button a
> >>> user clicks to allow for multiple row selection (which I want to be in
> >>> sync with the checkedtextview states, when a row is clicked)
>
> >>> @Override
> >>> protected void onListItemClick(ListView l, View v, int position, long
> >>> id) {
> >>> super.onListItemClick(l, v, position, id);
> >>> try {
> >>> multiselect = (ImageButton) findViewById(R.id.multiselect);
> >>> // multiselect.getTag().toString() == "1"
> >>> if (checkedstate == 1) {
> >>> // Set the Checkbox in explore.xml to checked or unchecked when
> >>> user clicks on row
> >>> ctv = (CheckedTextView) findViewById(R.id.ctv);
> >>> ctv.toggle();
>
> >>> if(ctv.isChecked() == true){
>
> >>> f = new File(root + item.get(position) + ".txt");
> >>> filesArray.add(f.toString());
> >>> //
> >>> //
> >>> // for(int i=0; i< lv.getCheckItemIds().length; i++){
> >>> // Log.i("getCII", lv.getCheckItemIds()[i]+"");
> >>> // }
> >>> Log.i("checked", "checked");
> >>> }else if (ctv.isChecked() == false){
> >>> for(int i=0; i< filesArray.size(); i++){
> >>> if(f.toString() == filesArray.get(i).toString()){
> >>> filesArray.remove(i);
> >>> // Log.i("not checked", filesArray.get(i).toString());
> >>> }
> >>> }
> >>> Log.i("not checked", "not checked");
> >>> }
>
> >>> Thanks.
>
> >>> On Jun 24, 5:58 am, Mickey<michele.pri...@gmail.com> wrote:
>
> >>>> Hi,
> >>>> I'm not sure if I truly understood your problem but one thing I would
> >>>> suggest is to check the API Demos app that is shipped with the SDK, if
> >>>> you haven't done yet.
>
> >>>> In particular, there's a class named List11.java which gives you a
> >>>> brief overview on how to use the CheckedTextView.
>
> >>>> In the case you still have problem, you might want to post some code
> >>>> in order to make this clear.
>
> >>>> Cheers,
>
> >>>> Mic
>
> >>>> On Jun 8, 3:08 am, SirAndroidDev<bud...@gmail.com> wrote:
>
> >>>>> I'm really frusterated at this point, three days in. I've put many
> >>>>> hours into this issu and am no closer to having a working (let alone
> >>>>> proper) solution. Why is this so painful to accomplish I wonder
> >>>>> aloud.
>
> >>>>> Problem:
>
> >>>>> I've got a a ListView which has a row.xml for each row in the
> >>>>> ListView. That file has two TextView's, ImageView, and aCheckedTextView.
>
> >>>>> Now, I can get oneCheckedTextViewto become checked by pressing on
> >>>>> its UI area. But, I cannnot not check any other unchecked checkbox in
> >>>>> the ListView.
>
> >>>>> Further more I see checkboxes when I scroll down that have checkmarks
> >>>>> in them where I did not check such myself.
>
> >>>>> So, what is the issue? One of you google engineers surely can explain
> >>>>> this to us end-devs, better yet please supply a sample project. I
> >>>>> have each row also where the user can select a file and work is done
> >>>>> with it when that path is pasted back to the main activity (which
> >>>>> works fine).
>
> >>>>> I have half the hair I had 72 hours ago (because I pulled half out).
> >>>>> Please, please help those of us struggling with this important feature
> >>>>> (CheckedTextView). As I see several posts about this, anything from
> >>>>> implement Clickable on the class (which I did, both trying on the main
> >>>>> java file and as a helper class) toCheckedTextViewhas to be the
> >>>>> parent in the xml file (not say a LinearLayout for example).
>
> >>>>> Please...... help... drowing ..... in ... stess.
>
> >>>>> Thank you- Hide quoted text -
>
> >>>> - Show quoted text -
>
> >> --
> >> Sincerely,
>
> >> Brad Gies
> >> -----------------------------------------------------------------------
> >> Bistro
>
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment