Android with PURE Java Code is possible?

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

Android with PURE Java Code is possible?

Postby c3r13e12u5 » Fri Oct 10, 2008 10:05 am

Is it possible to use Android APIs without any XML?
Im having trouble on creating ListView without any "R.Layout.myLayout" to put on my
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ArrayAdapter<String>(context, R.layout.myLayout)
Parsed in 0.029 seconds, using GeSHi 1.0.8.4
.
why cant i just put
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ArrayAdapter<String>(context,new TextView())
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

why it has to be an (int) ID from Resource?
what is the simplest way to make a ListView?
please help.
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Top

Postby MrSnowflake » Fri Oct 10, 2008 11:48 am

It's indeed strange, but you could implement an extension to arrayadapter.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby plusminus » Fri Oct 10, 2008 2:14 pm

Hello c3r13e12u5,

You can simply extend ListAdapter. There you'll find methods to override, like [font=Courier New].getView()[/font].

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

Postby c3r13e12u5 » Mon Oct 13, 2008 7:58 am

Thank you for the reply MrSnowFlake and PlusMinus!

Currently I use:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myList.setAdapter(new ArrayAdapter<String>(activity,R.layout.simple_list_item_1,items));
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


"R.layout.simple_list_item_1" was accessible by my project.
Is this a standard layout provided by Android?
I could not see what is written on "simple_list_item_1".
m'I right to use this in my project?
c3r13e12u5
Developer
Developer
 
Posts: 28
Joined: Wed Oct 08, 2008 7:33 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 7 guests