1 Replies - 2824 Views - Last Post: 11 October 2012 - 04:34 PM

#1 manowar689  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 26-September 10

Help with creating a GUI component programatically

Posted 11 October 2012 - 07:29 AM

Hello i was hoping somebody could help me here I am having a bit of trouble here i am hoping to design an android app that will have dynamically generated GUI's based on content in a MySQL database and am hoping to create a class with a user defined constructor which will allow me to create an item in a list activity without the use of an XML file my code is

public class ConnectionListView extends ListActivity{
    

	
	
	public ConnectionListView(Context context,String Label,String Ip){
		
			
			
						
	}
	
	public static LinearLayout getLayout(Context context,String Label,String Ip){
		
		LinearLayout ll = new LinearLayout(context);
		TextView textLabel = new TextView(context);
		TextView textIp = new TextView(context);
		
		textLabel.setText(Label);
		textIp.setText(Ip);
		
		textLabel.setHeight(30);
		textIp.setHeight(10);
		
		//=======================================================================================================
		
		ll.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		ll.setGravity(Gravity.TOP);
		ll.setOrientation(LinearLayout.VERTICAL);
		
		ll.addView(textLabel);
		ll.addView(textIp);
		
		return ll;
		
	}
	
}


i know the code is a mile away from what it needs to be but has anyone any idea on how i would even start on this or could even point me in the right direction it would be greatly appreciated thanks in advance for the help :D
also i have done an image in paint which I attached which I hope can give you some help in understanding my more then likely terrible explanation LOL

Is This A Good Question/Topic? 0
  • +

Replies To: Help with creating a GUI component programatically

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 278
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: Help with creating a GUI component programatically

Posted 11 October 2012 - 04:34 PM

Look at this tutorial: http://www.vogella.c...ew/article.html . It should show you how to create work with a listview.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1