view and subview

by Jags » Sat, 17 Jul 2010 20:47:05 GMT


Sponsored Links
 is there a way i can create a view and add some textviews into it ?
programmatically ? any sample code ?

regards

--



view and subview

by grace » Mon, 19 Jul 2010 14:28:52 GMT


 hi please check out the sample code for creating views and viewGroups
without a xml


public class tut3 extends Activity {

    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);



        ScrollView sv = new ScrollView(this);

        LinearLayout ll = new LinearLayout(this);

        ll.setOrientation(LinearLayout.VERTICAL);

        sv.addView(ll);



        TextView tv = new TextView(this);

        tv.setText("Dynamic layouts ftw!");

        ll.addView(tv);



        EditText et = new EditText(this);

        et.setText("weeeeeeeeeee~!");

        ll.addView(et);



        Button b = new Button(this);

        b.setText("I don't do anything, but I was added
dynamically. :)");

        ll.addView(b);



        for(int i = 0; i < 20; i++) {

                CheckBox cb = new CheckBox(this);

                cb.setText("I'm dynamic!");

                ll.addView(cb);

        }

        this.setContentView(sv);

    }

}





--


Sponsored Links


Other Threads

1. java.io.FileNotFoundException:No files supported by provider

Hi,

I am trying to insert images into my custom content provider.
this is my piece of code where i try to insert..

  ContentValues values = new ContentValues();
            values.put(ImageProvider.KEY_ID, position);
            values.put(ImageProvider.KEY_TITLE,"bluezz.png");
            Uri insertedUri =
getContentResolver().insert(Uri.parse(ImageProvider.CONTENT_URI),
values);
            try {
                OutputStream outStream =
getContentResolver().openOutputStream(insertedUri);///LINE 1
                b.compress(Bitmap.CompressFormat.PNG, 50, outStream);
                outStream.close();
            } catch (Exception e) {
                Log.e(ImageProvider.TAG, "exception while writing
image", e);
            }

but this(LINE 1) is throwing me up with an exception "
java.io.FileNotFoundException:No files supported by provider."

I have searched a lot on internet for the solution but in vain.
can anybody please provide some solution for my problem

Thanks in advance,
Grace.




-- 

2. how to enable logging (logcat) by default, during android boot

>Is there other solution? This has print overhead,
this is printed via log thread asynchronously, which is running at lower
priority., not like kernel side prints.
this will increase system load a bit, but definitely not at the cost of
responsiveness other running threads.,

-- 
Regards,
Deva
www.bittoggler.com


2010/5/28 dofm...@gmail.com <dofm...@gmail.com>



> website: 

3. How to get non-removal SD card storage information?

4. Vertical Tab View

5. Not able to update values of other activity in the current one

6. Why doesn't my 2d polygon get filled?

7. Location API. Detecting proximity to a given point