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 <[email protected]> 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 <[email protected]> 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 <[email protected]> > 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 <[email protected]> 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 <[email protected]> > > > 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 > > > [email protected] > > > > > To unsubscribe from this group, send email to > > > > > [email protected]<android-developers%[email protected]> > <android-developers%[email protected]<android-developers%[email protected]> > > > > > <android-developers%[email protected]<android-developers%[email protected]> > <android-developers%[email protected]<android-developers%[email protected]> > > > > > > > > > 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 > [email protected] > > > To unsubscribe from this group, send email to > > > [email protected]<android-developers%[email protected]> > <android-developers%[email protected]<android-developers%[email protected]> > > > > > 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 [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > 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 [email protected] To unsubscribe from this group, send email to [email protected] 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.

