Create GUI using just JAVA code?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Create GUI using just JAVA code?

Postby Kastagire » Thu May 01, 2008 2:28 pm

Hi all,
I am new to Android and Java, and I was wondering, is it possible to build a GUI in Android without using the XML file, just using Java swing or awt to build a simple interface? If so, how can I go about doing it?

Thanks! You guys have been great with my questions!

-Kasta
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Top

Postby faldureon » Thu May 01, 2008 8:35 pm

If its possible to do something with a widget in XML, it is possible to do the same thing with it in code. It is very unfortunate that all the examples google provides are in XML, since I find it harder to learn the UI side unless I get to see the code. If you need some examples of xml-free widgets - take a look at my android project - Geocast. I do not use any XML to define my widgets. In my code you can find examples of TextView, EditText, ScrollView, ImageView, Button, RadioButton, MapView, ListView, LinearLayout, AbsoluteLayout, TabHost and some others.
faldureon
Developer
Developer
 
Posts: 27
Joined: Sun Dec 02, 2007 10:19 pm

Postby Kastagire » Thu May 01, 2008 8:41 pm

Awesome, Thanks!!!
Kastagire
Junior Developer
Junior Developer
 
Posts: 10
Joined: Tue Apr 29, 2008 8:47 pm

Postby snowtiger » Mon May 05, 2008 9:23 am

faldureon wrote:If its possible to do something with a widget in XML, it is possible to do the same thing with it in code.

That's not the full truth. There are some XML statements you don't have a corresponding Java method. (android:nextFocusXYZ, android:scrollbarXYZ, ...)
snowtiger
Developer
Developer
 
Posts: 34
Joined: Fri Dec 21, 2007 10:44 am

Postby plusminus » Fri May 23, 2008 9:37 am

Hey guys,

making the UIs with XML is highly preferable :!:
Its incredibly easy to adapt your whole application to another screen-format without touching any existing line of code :!:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

TabHost with MapView and ListView?

Postby joos » Fri May 23, 2008 10:42 pm

Hello,
does anyone have an example of a TabHost with a MapView (Tab1) and ListView (Tab2).

I believe there is only one Activity "behind" a screen. If you want to have a TabHost with a MapView (Tab1) and ListView (Tab2), would need an Activity that is both (?). I didn't look into it so deeply, but so far I don't know how to do this.

Does anyone have an insight?

Greetings,
Joos
joos
Freshman
Freshman
 
Posts: 4
Joined: Thu May 22, 2008 6:59 pm

Top

Postby faldureon » Sat May 24, 2008 7:06 pm

I believe there is only one Activity "behind" a screen. If you want to have a TabHost with a MapView (Tab1) and ListView (Tab2), would need an Activity that is both (?). I didn't look into it so deeply, but so far I don't know how to do this.

You must have a map activity to use a mapview. You do not need a TabActivity to display a tab host. So to get a Mapview inside a tabhost you need to use a MapActivity that has a tabhost as its content. You must initialize the map if you use a MapActivity so make sure that happens even if the MapView tab isn't the first one to be displayed. The activity behind Geocast is a MapActivity with a Tabhost with a MapView as one of the tabs. You can look at it here


making the UIs with XML is highly preferable

That is the common wisdom, but I just don't trust uncompiled xml files enough as a way to define how my application behaves. Maybe once the refactoring and auto completion for the ui xml files gets better I'll start using them
faldureon
Developer
Developer
 
Posts: 27
Joined: Sun Dec 02, 2007 10:19 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests