user3002166
user3002166

Reputation: 730

list item custom layout

I'm following an android book for beginners and stumbled upon something I don't understand...

I'm to make a TimelineFragment class where one section looks like this:

private static final int[]
        TO = {
        R.id.list_item_text_user,
        R.id.list_item_text_message,
        R.id.list_item_text_created_at,
        R.id.list_item_freshness
};

where all list_item_xxx are undefined and generate errors(quite obviously), a bit later the author just throws something he called R.layout.list_item where those custom layouts are defined, however at no place he said where to put this xml of custom list layout. Could someone tell me where should I normally put those definition? The autofix wants to edit R.java (I already know this is a bad idea) or create ID value resource which I don't know what it is, as I thought ID-value is simply key-value pair.

//I'm so tired with all books and tutorials taking "shortcuts" that end up with beginners stumbling in the dark.

Upvotes: 0

Views: 74

Answers (2)

vipluv
vipluv

Reputation: 607

Look inside your 'res' folder. You will see a folder called 'layout'. Add the file in this folder.

EDIT: The android R-file basically creates entries corresponding to all elements in your project's resources automatically. Each time you add an xml resource with some xml elements that have ids, you can then access these elements programmatically through R.id.xx If you add a drawable (like an image resource, for example) into the drawable folder then you can access it using R.drawable.xx, etc. Read some of the links in the other answers for a clearer understanding! :-)

Upvotes: 1

Byron
Byron

Reputation: 1313

This will go in the res/layout folder of your project. You can see more information here: http://developer.android.com/guide/topics/ui/declaring-layout.html

Upvotes: 1

Related Questions