Dynamic GUI

Quickly share your Android Code Snippets here...

Dynamic GUI

Postby alpesh » Wed Oct 06, 2010 6:43 am

Hi

I m new developer, I have created one forum statically using xml gui.

But, i want to develop same forum dynamically writing java code

send me any example for that :cry:
alpesh
Developer
Developer
 
Posts: 25
Joined: Wed Oct 06, 2010 6:22 am
Location: Ahmedabad - gujarat - india

Top

Re: Dynamic GUI

Postby Sathasivan » Wed Oct 06, 2010 8:33 am

hai alpesh,

i just created one example for creating textviews dynamically,

my activity as follow,

package com.DynamicGUI;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;

public class DynamicGUI extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

LinearLayout LL_Dynamic = (LinearLayout) findViewById(R.id.LL_Dynamic);

LayoutParams LP = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

for (int i=0; i<10; i++){
TextView textView = new TextView(this);
textView.setText("Dynamic TextView " + (i+1));
textView.setTextSize(18);
textView.setLayoutParams(LP);
LL_Dynamic.addView(textView);
}

}
}


also my xml is,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/LL_Dynamic">

<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Dynamic GUI"/>

</LinearLayout>


by this example you may get some ideas to do your task.
User avatar
Sathasivan
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Wed Oct 14, 2009 7:51 am
Location: Chennai

Re: Dynamic GUI

Postby alpesh » Wed Oct 06, 2010 9:28 am

Thanks buddy.. I will try to implement right know... But there is one question.. in my mind..

It is possible that If write some code in xml and later on i want add something on that dynamically.
For Example
ScrollView..
LinearLayout ...
CheckBox
/Lie...
/Sroll..
& I want add number of check box dynamically... Is it possible..
Thanks.. for reply
alpesh
Developer
Developer
 
Posts: 25
Joined: Wed Oct 06, 2010 6:22 am
Location: Ahmedabad - gujarat - india

Re: Dynamic GUI

Postby Sathasivan » Wed Oct 06, 2010 2:30 pm

ya its possible
User avatar
Sathasivan
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Wed Oct 14, 2009 7:51 am
Location: Chennai

Re: Dynamic GUI

Postby alpesh » Wed Oct 06, 2010 3:09 pm

Thanks for reply
Yes , i tried it , it working fine..

One more Question.. How can i swap the screen in android..?? When i click on button i want give effect on transaction.
is there any way for that ..?
alpesh
Developer
Developer
 
Posts: 25
Joined: Wed Oct 06, 2010 6:22 am
Location: Ahmedabad - gujarat - india

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 3 guests