-
Notifications
You must be signed in to change notification settings - Fork 0
/
LayoutViewer.java
61 lines (51 loc) · 1.79 KB
/
LayoutViewer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//TODO:
//NEED TO PULL THE ITEMS FROM DATABASE INSTEAD OF CREATING THEM IN THIS ACTIVITY
//NEED TO MODIFY ItemView SO THAT IT CREATES THE VIEWS DYNAMICALLY DEPENDING ON THE DATATYPE
package com.mollys.db;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
public class LayoutViewer extends Activity {
private DBManager dbm;
private List<Item> lsItems;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_viewer);
//INITIALIZE THE DESCRIPTION OF TWO ITEMS
HashMap<String,Object> hmDesc1=new HashMap<String,Object>();
hmDesc1.put("type", new String("TextView"));
hmDesc1.put("text", new String("I am Item 1"));
hmDesc1.put("color", (int)Color.GREEN);
HashMap<String,Object> hmDesc2=new HashMap<String,Object>();
hmDesc2.put("type", new String("EditText"));
hmDesc2.put("text", new String("I am Item 2"));
//CREATE THE ITEM ITSELF
Item it1=new Item(hmDesc1);
Item it2=new Item(hmDesc2);
//ADD THIS ITEM TO A LIST OF ITEMS
this.lsItems=new ArrayList<Item>();
lsItems.add(it1);
lsItems.add(it2);
//INITIALIZE THE LISTVIEW
showLayout(lsItems);
}
public void showLayout(List<Item> lsItems);
{
LinearLayout ll=(LinearLayout) getViewById(R.id.layout_viewer_layout);
ll.addView(lsItems)
}
}