in the onClick you also have

v.getContext();
v.getParent();
v.getRootView();


On Sat, Mar 27, 2010 at 4:41 PM, Adrian Vintu <adrianvi...@gmail.com> wrote:

> A. create one time the container view then use setVisibility() to show or
> hide it
> or/and
> B. you also have alert.getOwnerActivity() which gives you back the...
> context :) you can then play around with it as you wish
>
>
>
> On Sat, Mar 27, 2010 at 4:36 PM, rubeN_vl <rvanluch...@hotmail.com> wrote:
>
>> Same error,
>>
>> how can such a simple thing be so difficult :D
>>
>> if i create those outside the onclick scope, its like i can use them
>> only one time.
>> final TableRow tr = new TableRow(this);
>> final TextView b = new TextView(this);
>>
>> On 27 mrt, 16:16, Adrian Vintu <adrianvi...@gmail.com> wrote:
>> > So toggle the visibility from GONE to VISIBLE. I think this would be a
>> quick
>> > solution :)
>> >
>> > BR,
>> > Adrian Vintu
>> >
>> > http://adrianvintu.com
>> >
>> > On Sat, Mar 27, 2010 at 4:14 PM, Adrian Vintu <adrianvi...@gmail.com>
>> wrote:
>> > > It's my pleasure to help :)
>> >
>> > > I think an easy solution is to use view.setVisibility(View.GONE)
>> >
>> > > Does this work for you?
>> >
>> > > BR,
>> > > Adrian Vintu
>> >
>> > >http://adrianvintu.com
>> >
>> > > On Sat, Mar 27, 2010 at 4:10 PM, rubeN_vl <rvanluch...@hotmail.com>
>> wrote:
>> >
>> > >>  checkboxrifle.setOnClickListener(new View.OnClickListener() {
>> > >>            public void onClick(View v) {
>> > >>                Patient p = (Patient) spinner.getSelectedItem();
>> > >>                Service s = new Service("RIFLE");
>> > >>                if (((CheckBox) v).isChecked()) {
>> > >>                        p.addService(s,0);
>> > >>                        DataAccess.registerService(p,s);
>> > >>                        //TableRow tr = new TableRow(this);
>> > >>                    //TextView b = new TextView(this);
>> > >>                        //tr.removeView(b);
>> > >>                        //TableLayout tl =
>> > >> (TableLayout)findViewById(R.id.dynatabel);
>> > >>                    //tl.removeView(tr);
>> >
>> > >>                    // b.setText("Dynamic tekst");
>> > >>                    // tr.addView(b);
>> > >>                        //tl.addView(tr);
>> > >>                } else {
>> > >>                    p.removeService(0);
>> > >>                    DataAccess.unregisterService(p, s);
>> > >>                }
>> > >>            }
>> > >>        });
>> >
>> > >> 1st of all tx for ur time.
>> > >> So, i want to do this, push a checkbox, get an object in a spinner,
>> > >> add a row to a tabel. Uncheck the checkbox and the row gets removed.
>> > >> If i create textview outside the scope, i can add 1 new row to the
>> > >> table. Second time i check the checkbox i get the error described
>> > >> previously.
>> > >> The removeView() just removes the view, the application does not
>> > >> crash, but no new rows are added. It just removes the previously
>> > >> created View and creates a new one.
>> > >> If i can create the textview inside the scope the prob would be fixed
>> > >> i think, just need something else then the 'this' when creatin a new
>> > >> one.
>> >
>> > >> On 27 mrt, 15:58, Adrian Vintu <adrianvi...@gmail.com> wrote:
>> > >> > you should probably call removeView() :)) sorry, i could not help
>> it :))
>> >
>> > >> > how about you just add the textview one time only?
>> >
>> > >> > or how about you just post your code?
>> >
>> > >> > BR,
>> > >> > Adrian Vintu
>> >
>> > >> >http://adrianvintu.com
>> >
>> > >> > On Sat, Mar 27, 2010 at 3:52 PM, rubeN_vl <rvanluch...@hotmail.com
>> >
>> > >> wrote:
>> > >> > > Yeah, figured out that yet, if i do that it works if i push the
>> button
>> > >> > > 1 time, the second time i push it the application just crashes.
>> > >> > > Logcat gives me this error: You must call removeView() on the
>> childs
>> > >> > > parent first.
>> > >> > > I need some way to 'flush' the textview.
>> >
>> > >> > > On 27 mrt, 15:44, Adrian Vintu <adrianvi...@gmail.com> wrote:
>> > >> > > > Your code probably looks like this
>> > >> > > > AlertDialog a = builder.create();
>> >
>> > >> > > > a.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new
>> OnClickListener()
>> > >> > > > {
>> > >> > > >  public void onClick(DialogInterface dialog, int which)
>> > >> > > >  {
>> > >> > > >   TextView b = new TextView(this);
>> >
>> > >> > > >    ...
>> >
>> > >> > > > }
>> >
>> > >> > > > You need to create the TextView outside the scope of the
>> > >> OnClickListener.
>> > >> > > > The "this" has to point to Context, which is your Activity.
>> >
>> > >> > > > BR,
>> > >> > > > Adrian Vintu
>> >
>> > >> > > >http://adrianvintu.com
>> >
>> > >> > > > On Sat, Mar 27, 2010 at 3:28 PM, rubeN_vl <
>> rvanluch...@hotmail.com>
>> > >> > > wrote:
>> > >> > > > > Hi,
>> >
>> > >> > > > > i'm trying to create a new TextView when a button is clicked.
>> > >> > > > > TextView b = new TextView(this); isnt working cause 'this'
>> refers
>> > >> to
>> > >> > > > > new View.onClickListener.
>> > >> > > > > Been searchin for hours, cant find a solution.
>> >
>> > >> > > > > --
>> > >> > > > > 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
>> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>> >
>> > >> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>> <android-developers%252bunsubscr...@googlegroups.com<android-developers%25252bunsubscr...@googlegroups.com>
>> >
>> >
>> > >> > > <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>> <android-developers%252bunsubscr...@googlegroups.com<android-developers%25252bunsubscr...@googlegroups.com>
>> >
>> > >> <android-developers%252bunsubscr...@googlegroups.com<android-developers%25252bunsubscr...@googlegroups.com>
>> <android-developers%25252bunsubscr...@googlegroups.com<android-developers%2525252bunsubscr...@googlegroups.com>
>> >
>> >
>> > >> > > > > For more options, visit this group at
>> > >> > > > >http://groups.google.com/group/android-developers?hl=en
>> >
>> > >> > > > > To unsubscribe from this group, send email to
>> android-developers+
>> > >> > > > > unsubscribegooglegroups.com or reply to this email with the
>> words
>> > >> > > "REMOVE
>> > >> > > > > ME" as the subject.
>> >
>> > >> > > --
>> > >> > > 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
>> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>> >
>> > >> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>> <android-developers%252bunsubscr...@googlegroups.com<android-developers%25252bunsubscr...@googlegroups.com>
>> >
>> >
>> > >> > > For more options, visit this group at
>> > >> > >http://groups.google.com/group/android-developers?hl=en
>> >
>> > >> > > To unsubscribe from this group, send email to android-developers+
>> > >> > > unsubscribegooglegroups.com or reply to this email with the
>> words
>> > >> "REMOVE
>> > >> > > ME" as the subject.
>> >
>> > >> --
>> > >> 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
>> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
>> >
>> > >> For more options, visit this group at
>> > >>http://groups.google.com/group/android-developers?hl=en
>> >
>> > >> To unsubscribe from this group, send email to android-developers+
>> > >> unsubscribegooglegroups.com or reply to this email with the words
>> "REMOVE
>> > >> ME" as the subject.
>>
>> --
>> 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+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>>
>> To unsubscribe from this group, send email to android-developers+
>> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
>> ME" as the subject.
>>
>
>

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to