Android add row to table on button click - java

I have a TableLayout in my application. I have Two definite Rows so far. One Row has static items assigned to it, and the other has 3 spinners assigned top it.
What I'd like to do is, add a new TableRow when ever I click on a button. So far I have the following code:
<TableRow
android:layout_width="fill_parent">
android:stretchColumns="0,1,2"
<Spinner
android:padding="3dip"
android:gravity="left"
android:id="#+id/Spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
<Spinner
android:padding="3dip"
android:gravity="left"
android:id="#+id/Spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
<Spinner
android:padding="3dip"
android:gravity="left"
android:id="#+id/spinner3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
</TableRow>
This is just me second row, the row that I want to add when ever I click said button. MY question is, how do I add the following row into my view, every time the user clicks the button? The values of the spinners will differ, but the variables will stay the same.
Edit:
More code:
/* Find Tablelayout defined in teh XML file */
TableLayout tl = (TableLayout) findViewById(R.id.listTable);
/* Create a new row to be added. */
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
/* Create a Button to be the row-content. */
Button b = new Button(this);
b.setText("Add row");
b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
/* Add Button to row. */
tr.addView(b);
/* Add row to TableLayout. */
tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
}
View changed to this:
<TableRow
android:id="#+id/copyRow"
android:layout_width="fill_parent" >
android:stretchColumns="0,1,2"
<Spinner
android:padding="3dip"
android:gravity="left"
android:id="#+id/Spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
<Spinner
android:padding="3dip"
android:gravity="left"
android:id="#+id/Spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
<Spinner
android:padding="3dip"
android:gravity="left"
android:id="#+id/spinner3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp" />
</TableRow>
If It makes a difference, I'm using JellyBean 4.3 as the target API

here is solution with ListView
you can finde all source code here
Activity Class
public class MainActivity extends Activity {
private List<RowItem> rows = new ArrayList<RowItem>();
private ListView list;
private Button addButton;
private SimpleListAdapter listAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get view elements
list = (ListView)findViewById(R.id.list);
addButton = (Button)findViewById(R.id.addButton);
//lets add few items to our list, note that selection item should not exceed length of spinners item
rows.add(new RowItem(0, 0, 0));
rows.add(new RowItem(0, 1, 2));
rows.add(new RowItem(2, 1, 1));
//create adapter and assign it to your list view
listAdapter = new SimpleListAdapter(this, R.layout.list_item, rows);
list.setAdapter(listAdapter);
addButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
rows.add(new RowItem(0, 0, 0));
listAdapter.notifyDataSetChanged();
}
});
}
Adapter Class
public class SimpleListAdapter extends ArrayAdapter<RowItem>{
private Context context;
private int layoutResourceId;
private List<RowItem> data = null;
private ArrayList<String> spinnerArray1 = new ArrayList<String>();
private ArrayList<String> spinnerArray2 = new ArrayList<String>();
private ArrayList<String> spinnerArray3 = new ArrayList<String>();
public SimpleListAdapter(Context context, int layoutResourceId, List<RowItem> data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = data;
spinnerArray1.add("S1 One");
spinnerArray1.add("S1 Two");
spinnerArray1.add("S1 Three");
spinnerArray2.add("S2 One");
spinnerArray2.add("S2 Two");
spinnerArray2.add("S2 Three");
spinnerArray3.add("S3 One");
spinnerArray3.add("S3 Two");
spinnerArray3.add("S3 Three");
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
ItemHolder holder;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new ItemHolder();
holder.Spinner1 = (Spinner)row.findViewById(R.id.Spinner1);
holder.Spinner2 = (Spinner)row.findViewById(R.id.Spinner2);
holder.Spinner3 = (Spinner)row.findViewById(R.id.Spinner3);
//add adapter to spinners so that there is something to select from
ArrayAdapter<String> spinnerArrayAdapter1 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArray1);
holder.Spinner1.setAdapter(spinnerArrayAdapter1);
ArrayAdapter<String> spinnerArrayAdapter2 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArray2);
holder.Spinner2.setAdapter(spinnerArrayAdapter2);
ArrayAdapter<String> spinnerArrayAdapter3 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_dropdown_item, spinnerArray3);
holder.Spinner3.setAdapter(spinnerArrayAdapter3);
row.setTag(holder);
}
else
{
holder = (ItemHolder)row.getTag();
}
final RowItem rowItem = data.get(position);
holder.Spinner1.setSelection(rowItem.getSelectionIndex1());
holder.Spinner2.setSelection(rowItem.getSelectionIndex2());
holder.Spinner3.setSelection(rowItem.getSelectionIndex3());
holder.Spinner1.setOnItemSelectedListener(new OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Toast.makeText(context, "you selected an item from spinner 1", Toast.LENGTH_SHORT).show();
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
return row;
}
class ItemHolder{
Spinner Spinner1;
Spinner Spinner2;
Spinner Spinner3;
}
simple model
public class RowItem {
private int selectionIndex1;
private int selectionIndex2;
private int selectionIndex3;
public RowItem(int selectionIndex1, int selectionIndex2, int selectionIndex3) {
super();
this.selectionIndex1 = selectionIndex1;
this.selectionIndex2 = selectionIndex2;
this.selectionIndex3 = selectionIndex3;
}
public int getSelectionIndex1() {
return selectionIndex1;
}
public void setSelectionIndex1(int selectionIndex1) {
this.selectionIndex1 = selectionIndex1;
}
public int getSelectionIndex2() {
return selectionIndex2;
}
public void setSelectionIndex2(int selectionIndex2) {
this.selectionIndex2 = selectionIndex2;
}
public int getSelectionIndex3() {
return selectionIndex3;
}
public void setSelectionIndex3(int selectionIndex3) {
this.selectionIndex3 = selectionIndex3;
}
}
View items: Main view
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical"
android:gravity="center" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:dividerHeight="5dp"/>
<Button
android:id="#+id/addButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Add Item"
/>
item renderer for list view
<?xml version="1.0" encoding="utf-8"?>
<Spinner
android:id="#+id/Spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="left"
android:padding="3dip" />
<Spinner
android:id="#+id/Spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="left"
android:padding="3dip" />
<Spinner
android:id="#+id/Spinner3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="left"
android:padding="3dip" />

Related

How to Change Text Color, Size and Font in a Dynamically Created ListView

I am trying to make a to-do list using an EditText and a ListView. How can I change the text font, color and size? I have seen a couple answers using array adapters, but don't know how to apply them to dynamically created ListView items.
Here is what I have so far:
ActivityMain.xml
<RelativeLayout
android:id="#+id/AgendaRL"
android:orientation="vertical"
android:background="#3E2723"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/agenda"
android:layout_width="370sp"
android:layout_height="wrap_content"
android:text="#string/agenda"
android:textSize="40sp"
android:textColor="#b7950b"
android:layout_marginTop="12sp"
android:layout_marginLeft="12sp"
android:layout_marginStart="12sp"
android:layout_marginBottom="0sp" />
<View
android:background="#b7950b"
android:layout_below="#+id/agenda"
android:layout_width="28sp"
android:layout_height="36sp"/>
<EditText
android:id="#+id/aTask"
android:layout_below="#+id/agenda"
android:background="#drawable/ribbon"
android:inputType="text"
android:text="#string/Add_Task"
android:textColor="#3E2723"
android:maxLength="22"
android:maxLines="1"
android:layout_width="330sp"
android:layout_height="36sp"
android:textSize="28sp"
android:layout_marginLeft="28sp"
android:layout_marginStart="28sp"/>
<Button
android:id="#+id/Done"
style="?android:attr/borderlessButtonStyle"
android:layout_marginLeft="250sp"
android:layout_marginStart="250sp"
android:background="#b7950b"
android:text="#string/Done"
android:textColor="#3E2723"
android:textSize="18sp"
android:layout_below="#+id/agenda"
android:layout_width="48sp"
android:layout_height="36sp"
android:onClick="DoneClick"/>
<ListView
android:id="#+id/LVAgenda"
android:layout_below="#+id/aTask"
android:divider="#android:color/transparent"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
MainActivity.Java
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView LVAgenda = (ListView) findViewById(R.id.LVAgenda);
arrayListAgenda = new ArrayList<String>();
arrayAdapterAgenda = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arrayListAgenda);
LVAgenda.setAdapter(arrayAdapterAgenda);
}
public void DoneClick(View v){
EditText aTask = (EditText)findViewById(R.id.aTask);
String agenda = aTask.getText().toString().trim();
if(agenda.isEmpty()){
return;
}
arrayAdapterAgenda.add(agenda);
aTask.setText("Add task");
}
As commonsware said you can use getView() of ArrayAdapter to do this.
I have implemented Facebook friend selector with ListAdapter. I will share the code. May be it helps. Please try.
First make a XML file in layout that defines the layout of each item of your 'to do list'.
In my case it is a facebook profile image and a checked textbox. (There is also a spacer for alignment)
Facebook.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:paddingLeft="10dp"/>
<CheckedTextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|right"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:textColor="#android:color/black"
android:textStyle="bold" />
</LinearLayout>
<View
android:id="#+id/spacer"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/white"/>
</LinearLayout>
Now prepare your data array. In my case it is custom class array where each element contains a facebook name, profilepic, and a boolean.
public class Item{
public final String text;
public final Drawable icon;
public boolean isChecked;
public Item(String text, Drawable icon, boolean ischeck) {
this.text = text;
this.icon = icon;
this.isChecked = ischeck;
}
#Override
public String toString() {
return text;
}
}
I call the below code by passing friendsArray from another activity.
final Item[] items = new Item[friendsArray.length];
try {
int a = 1;
for (int i = 0; i < friendsArray.length; i++) {
tsk = new DownloadImageTask();
Bitmap bmp = (Bitmap) tsk.execute(new RaceActivity.FriendInfo[]{friendsArray[i]}).get();
Resources res = getActivity().getResources();
drawable = new BitmapDrawable(res, bmp);
items[i] = new Item(friendsArray[i].name, drawable,false);
}
}
catch(Exception ex)
{
}
Now your data array is prepared. You can pass this to ListAdapter(items in my case).
Its nice to understand the working of a List adapter. I created a scrollable List. What this logic does is it reuses the Views while scrolling.
ListAdapter adapter = new ArrayAdapter<Item>(
getActivity(),
android.R.layout.select_dialog_item,
android.R.id.text1,
items){
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
FaceBookHolder fb = new FaceBookHolder();
if(convertView == null)
{
LayoutInflater inflater = (LayoutInflater) getActivity().getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.facebook,null);
fb.Name = (CheckedTextView) v.findViewById(R.id.name);
fb.img = (ImageView) v.findViewById(R.id.img);
fb.spacer = (View) v.findViewById(R.id.spacer);
fb.Name.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
CheckedTextView cv = (CheckedTextView)v;
if(cv.isChecked())
cv.setChecked(false);
else
cv.setChecked(true);
for(int i =0;i< items.length; i++)
{
if(items[i].text == cv.getText())
{
items[i].isChecked = cv.isChecked();
}
}
}
});
v.setTag(fb);
}
else
fb = (FaceBookHolder) v.getTag();
Item itm = items[position];
fb.Name.setText(itm.text);
fb.img.setImageDrawable(itm.icon);
fb.Name.setChecked(itm.isChecked);
return v;
}
};
you get the view in getView(), so you can modify it however you want.(change color , font etc)
Hope it helps! cheers!

Got a java.lang.IllegalStateException: The specified child already has a parent

I have added two LinearLayouts and on those layouts, I add dynamically Checkboxes. The final purpose is to store data in a database.
I am getting this error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.freedomkitchen.sonali.freedomkitchen/com.freedomkitchen.sonali.freedomkitchenAndroidApp.AddRecipes}:
java.lang.IllegalStateException: The specified child already has a
parent. You must call removeView() on the child's parent first.
Can you help me to find the problem, please? Thanks.
This is my code:
public class AddRecipes extends AppCompatActivity {
static int a=0,b=0,c=0,d=0;
static int id=0;
public int x;
int idvalueVeg;
int idvalueFruits;
int idvalueGrains;
int idvalueDairy;
int idvalueSeaFood;
int end_of_sup_ing;
int sup_ing_id;
ArrayList<String> Main_Ingredients;
ArrayList<String> Supporting_Ingredients;
LinearLayout ll;
LinearLayout ll2;
Spinner FoodCatValue;
public String MealSelected;
EditText RecipeNameValue;
public Spinner sItems;
private static final boolean AUTO_HIDE = true;
private static final int AUTO_HIDE_DELAY_MILLIS = 3000;
private static final int UI_ANIMATION_DELAY = 300;
private final Handler mHideHandler = new Handler();
private View mContentView;
private final Runnable mHidePart2Runnable = new Runnable() {
#SuppressLint("InlinedApi")
#Override
public void run() {
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
};
private View mControlsView;
private final Runnable mShowPart2Runnable = new Runnable() {
#Override
public void run() {
// Delayed display of UI elements
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.show();
}
mControlsView.setVisibility(View.VISIBLE);
}
};
private boolean mVisible;
private final Runnable mHideRunnable = new Runnable() {
#Override
public void run() {
hide();
}
};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.addrecipes);
ll = (LinearLayout) findViewById(R.id.chk_layout);
ll2 = (LinearLayout) findViewById(R.id.chk_layout2);
FoodCatValue = (Spinner)findViewById(R.id.spinnerFoodCat);
Resources res = getResources();
String[] Appetizers = res.getStringArray(R.array.Appetizer_Meals);
String[] Main_Course = res.getStringArray(R.array.Main_Course_Meals);
String[] Desserts = res.getStringArray(R.array.Desserts_Meals);
ArrayList<String> AppetizerList = new ArrayList<String>(Arrays.asList(Appetizers));
ArrayList<String> Main_CourseList = new ArrayList<String>(Arrays.asList(Main_Course));
ArrayList<String> DessertList = new ArrayList<String>(Arrays.asList(Desserts));
if(FoodCatValue.getSelectedItem().toString().equals("Appetizers")){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, AppetizerList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sItems = (Spinner) findViewById(R.id.spinnerMealCat);
sItems.setAdapter(adapter);
getMealSelectedVal();
}
else if(FoodCatValue.getSelectedItem().toString().equals("Main Course"))
{
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, Main_CourseList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sItems = (Spinner) findViewById(R.id.spinnerMealCat);
sItems.setAdapter(adapter);
getMealSelectedVal();
}
else if(FoodCatValue.getSelectedItem().toString().equals("Dessert")){
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, DessertList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sItems = (Spinner) findViewById(R.id.spinnerMealCat);
sItems.setAdapter(adapter);
getMealSelectedVal();
}
RecipeNameValue =(EditText)findViewById(R.id.RecipeName);
DB_Access mydb=new DB_Access(this);
ArrayList<String> Vegetables=mydb.getIngredients(1);
ArrayList<String> Fruits=mydb.getIngredients(2);
ArrayList<String> Dairy=mydb.getIngredients(3);
ArrayList<String> Grains=mydb.getIngredients(4);
ArrayList<String> Seafood=mydb.getIngredients(5);
ArrayList<String> Sup_Ing=mydb.getSupportingIngredients();
final TextView VegTv = new TextView(this);
VegTv.setText("Vegetables");
ll.addView(VegTv);
for (x=0;x<Vegetables.size(); x++,id++) {
final CheckBox checkbox = new CheckBox(this);
checkbox.setId(id);
String Item = Vegetables.get(x);
checkbox.setText(Item);
ll.addView(checkbox);
idvalueVeg=id;
}
TextView FruitsTv = new TextView(this);
FruitsTv.setText("Fruits");
ll.addView(FruitsTv);
for (x=0;x<Fruits.size(); x++,id++) {
CheckBox checkbox = new CheckBox(this);
checkbox.setId(id);
String Item = Fruits.get(x);
checkbox.setText(Item);
ll.addView(checkbox);
idvalueFruits=id;
}
TextView GrainsTv = new TextView(this);
GrainsTv.setText("Grains");
ll.addView(GrainsTv);
for (x=0;x<Grains.size(); x++,id++) {
CheckBox checkbox = new CheckBox(this);
checkbox.setId(id);
String Item = Grains.get(x);
checkbox.setText(Item);
ll.addView(checkbox);
idvalueGrains=id;
}
TextView DairyTv = new TextView(this);
DairyTv.setText("Dairy");
ll.addView(DairyTv);
for(x=0;x<Dairy.size(); x++,id++) {
CheckBox checkbox = new CheckBox(this);
checkbox.setId(id);
String Item = Dairy.get(x);
checkbox.setText(Item);
ll.addView(checkbox);
idvalueDairy=id;
}
TextView SeafoodTv = new TextView(this);
SeafoodTv.setText("Seafood");
ll.addView(DairyTv);
for(x=0;x<Seafood.size(); x++,id++) {
CheckBox checkbox = new CheckBox(this);
checkbox.setId(id);
String Item = Seafood.get(x);
checkbox.setText(Item);
ll2.addView(checkbox);
idvalueSeaFood=id;
}
TextView supIng = (TextView)findViewById(R.id.sup_ingTextView);
DairyTv.setText("Supporting Ingredients");
ll.addView(supIng);
sup_ing_id = idvalueSeaFood;
for(x=0;x<Sup_Ing.size(); x++,id++) {
CheckBox checkbox = new CheckBox(this);
checkbox.setId(id);
String Item = Sup_Ing.get(x);
checkbox.setText(Item);
ll.addView(checkbox);
end_of_sup_ing=id;
}
}
public void getMealSelectedVal(){
MealSelected= sItems.getSelectedItem().toString();
}
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
}
private void hide() {
// Hide UI first
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
}
mControlsView.setVisibility(View.GONE);
mVisible = false;
// Schedule a runnable to remove the status and navigation bar after a delay
mHideHandler.removeCallbacks(mShowPart2Runnable);
mHideHandler.postDelayed(mHidePart2Runnable, UI_ANIMATION_DELAY);
}
#SuppressLint("InlinedApi")
private void show() {
// Show the system bar
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
mVisible = true;
// Schedule a runnable to display UI elements after a delay
mHideHandler.removeCallbacks(mHidePart2Runnable);
mHideHandler.postDelayed(mShowPart2Runnable, UI_ANIMATION_DELAY);
}
public void btnAddRecipes(View v){
GetInfo();
DB_Access mydb=new DB_Access(this);
EditText ins =(EditText)findViewById(R.id.RecipeTextArea);
mydb.adduserRecipes(FoodCatValue.getSelectedItem().toString(),MealSelected,RecipeNameValue.getText().toString(), Main_Ingredients,Supporting_Ingredients,ins.getText().toString());
}
public void GetInfo(){
Main_Ingredients=new ArrayList<String>(200);
Supporting_Ingredients=new ArrayList<String>(200);
for(x=0;x<id;x++){
CheckBox cb=(CheckBox)findViewById(x);
if(cb.isChecked()){
{
String item=cb.getText().toString();
Main_Ingredients.add(item);
}
}
}
//disp main ing
for(int i=0;i<Main_Ingredients.size();i++){
Log.i("Main_Ing:",Main_Ingredients.get(i));
}
for(x=sup_ing_id;x<=end_of_sup_ing;x++){
CheckBox cb=(CheckBox)findViewById(x);
if(cb.isChecked()){
{
String item=cb.getText().toString();
Supporting_Ingredients.add(item);
}
}
}
for(int i=0;i<Supporting_Ingredients.size();i++){
Log.i("Sup_Ing:",Supporting_Ingredients.get(i));
}
}
}
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#cdd2ea"
android:id="#+id/RL"
android:orientation="vertical"
android:weightSum="1">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/sv"
android:fillViewport="true"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/buttonAddRecipes">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/l_layout"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Add a New Recipe"
android:id="#+id/textView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Food Category :"
android:id="#+id/textView11"
android:layout_marginTop="25dp"
android:layout_below="#+id/textView"
android:layout_alignParentStart="true"
android:layout_marginStart="47dp" />
<Spinner
android:layout_width="244dp"
android:layout_height="match_parent"
android:id="#+id/spinnerFoodCat"
android:entries="#array/Food_Cat"
android:layout_gravity="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Meal Category :"
android:id="#+id/textView12"
android:layout_marginTop="25dp"
android:layout_below="#+id/textView"
android:layout_alignParentStart="true"
android:layout_marginStart="47dp" />
<Spinner
android:layout_width="244dp"
android:layout_height="match_parent"
android:id="#+id/spinnerMealCat"
android:layout_gravity="center" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Recipe Name :"
android:id="#+id/textView13"
android:layout_marginTop="25dp"
android:layout_below="#+id/spinner"
android:layout_alignParentStart="true"
android:layout_marginStart="47dp" />
<EditText
android:layout_width="271dp"
android:layout_height="match_parent"
android:id="#+id/RecipeName"
android:hint="Enter Recipe Name"
android:layout_below="#+id/textView13"
android:layout_gravity="center_horizontal" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Main Ingredients:"
android:id="#+id/textView15"
android:layout_marginStart="47dp" />
<LinearLayout
android:orientation="vertical"
android:id="#+id/chk_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/sup_ingTextView"
android:layout_marginStart="47dp" />
<LinearLayout
android:orientation="vertical"
android:id="#+id/chk_layout2"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<TextView
android:layout_width="303dp"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Instructions :"
android:id="#+id/textView17"
android:layout_marginTop="25dp"
android:layout_below="#+id/textView15"
android:layout_alignParentStart="true"
android:layout_marginStart="25dp"
android:layout_marginRight="20dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/RecipeTextArea"
android:editable="true"
android:layout_marginTop="25dp"
android:enabled="true"
android:minLines="6"
android:maxLines="6"
android:isScrollContainer="true"
android:hint="Enter Recipe Instructions here."
android:background="#fafafa"
android:textIsSelectable="true"
android:focusable="true"
android:gravity="top"
android:padding="24dp"
style="#style/Base.TextAppearance.AppCompat.Large"
/>
</LinearLayout>
</ScrollView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Recipe"
android:id="#+id/buttonAddRecipes"
android:capitalize="words"
android:clickable="true"
android:longClickable="false"
android:background="#4052b5"
android:textColor="#fefefe"
android:textSize="#dimen/abc_select_dialog_padding_start_material"
android:onClick="btnAddRecipes"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
This exception is fired then you try to add some view twice to layout.
You copypasted your code and didn't change it here
TextView SeafoodTv = new TextView(this);
SeafoodTv.setText("Seafood");
ll.addView(DairyTv);
I beleive it should be
TextView SeafoodTv = new TextView(this);
SeafoodTv.setText("Seafood");
ll.addView(SeafoodTv);
To avoid such mistakes it's better to put static views in xml layout.

How to set an String Array to an Array Adapter in android List view with check box?

I am getting a string[] Array and storing it in an String array [variable mystrings],Now i want this array to display it in a list view with check box .
ec_checkbox_number.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="26dp"
android:text="number" />
<TextView
android:id="#+id/checkboxtextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/checkBox"
android:layout_alignBottom="#+id/checkBox"
android:layout_alignParentLeft="true"
android:layout_marginLeft="107dp"
android:text="TextView" />
</RelativeLayout>
ec_number_selection.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/meetingprofilename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:text="Profile Name:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/meetingprofilename"
android:layout_alignBottom="#+id/meetingprofilename"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/meetingprofilename"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/cancelnumberbutton"
android:layout_width="158dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/editText2"
android:text="Cancel" />
<Button
android:id="#+id/donenumberbutton"
android:layout_width="158dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/cancelnumberbutton"
android:text="Done" />
<ListView
android:id="#+id/numberselectionlistView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/cancelnumberbutton"
android:layout_alignParentLeft="true"
android:layout_below="#+id/editText1" >
</ListView>
</RelativeLayout>
CheckBoxData.java
public class CheckBoxData {
private String[] number;
public String[] getNumber() {
return number;
}
public void setNumber(String[] number) {
this.number = number;
}
}
MyConferenceNumber.java
public class EcConferenceNumber extends Activity{
ListView checkBoxNumberListView;
ConferenceAdapter adapter;
Button doneBtn,cancelBtn;
EditText profileName;
MyCustomAdapter dataAdapter = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ec_number_selection);
adapter = new ConferenceAdapter(this);
checkBoxNumberListView = (ListView) findViewById(R.id.numberselectionlistView);
doneBtn=(Button) findViewById(R.id.donenumberbutton);
cancelBtn=(Button) findViewById(R.id.cancelnumberbutton);
Intent intent = getIntent();
String[] myStrings = intent.getStringArrayExtra("strings");
List<String> strings =
new ArrayList<String>(Arrays.asList(myStrings));
System.out.println(""+strings);
dataAdapter = new MyCustomAdapter(this,
R.layout.ec_checkbox_number, strings);
checkBoxNumberListView.setAdapter(dataAdapter);
checkBoxNumberListView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
CheckBoxData country = (CheckBoxData) parent.getItemAtPosition(position);
Toast.makeText(getApplicationContext(),
"Clicked on Row: " + country.getNumber(),
Toast.LENGTH_LONG).show();
}
});
}
class MyCustomAdapter extends ArrayAdapter<String>{
private List<String> strings;
public MyCustomAdapter(Context context, int textViewResourceId, List<String> strings) {
super(context, textViewResourceId,strings);
this.strings=new ArrayList<String>();
this.strings.addAll(this.strings);
// TODO Auto-generated constructor stub
}
private class ViewHolder {
TextView code;
CheckBox name;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Log.v("ConvertView", String.valueOf(position));
if (convertView == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.ec_checkbox_number, null);
holder = new ViewHolder();
holder.code = (TextView) convertView.findViewById(R.id.checkboxtextView);
holder.name = (CheckBox) convertView.findViewById(R.id.checkBox);
convertView.setTag(holder);
holder.name.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v ;
CheckBoxData country = (CheckBoxData) cb.getTag();
Toast.makeText(getApplicationContext(),
"Clicked on Checkbox: " + cb.getText() +
" is " + cb.isChecked(),
Toast.LENGTH_LONG).show();
}
});
}
else {
holder = (ViewHolder) convertView.getTag();
}
return convertView;
}
}
}
The output what i am getting is..
For example:If String[] a={002,111,122} i want to display it in a listview with checkbox and i have to get the selected CheckBox text.But my output is displying like this
number
number
number
number
But i want the output like this ,
123
112
123
Since ,I am new to android i did not know how to set the array to output view.Any answers will be helpfull.
Paste your full xml code. There is no button in xml and some properties are missing.

Android List View Showing only one item from two

I'am trying to make a ListView that contains two items (two textView's)
Here is my code:
Header XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/txtHeader"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:textStyle="bold"
android:textSize="22dp"
android:textColor="#FFFFFF"
android:padding="10dp"
android:text="Shoping List"
android:background="#336699" />
</LinearLayout>
Hers is the row XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
<TextView android:id="#+id/prudctName"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textStyle="bold"
android:textSize="22sp"
android:textColor="#000000"
/>
<TextView android:id="#+id/productAmount"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textStyle="bold"
android:textSize="22sp"
android:textColor="#000000"
/>
</LinearLayout>
Here is the MAIN SCREEN XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<ListView
android:id="#+id/shoping_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Here is the class that represents the object containing the two filed:
public class ShopingListItem
{
public String productName;
public String procuctAmount;
public ShopingListItem(String _productName,String _productAmount)
{
this.procuctAmount=_productAmount;
this.productName=_productName;
}
}
Here is the Adapter class:
public class ShopingListItemAdapter extends ArrayAdapter<ShopingListItem>
{
public Context context;
public int layoutResourceId;
public ShopingListItem[] items;
public ShopingListItemAdapter(Context context,int layoutResourceId, ShopingListItem[] objects)
{
super(context, layoutResourceId, objects);
this.context=context;
this.layoutResourceId=layoutResourceId;
this.items=objects;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
ShopingListItemHolder holder = null;
if(row==null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new ShopingListItemHolder();
holder.productName=(TextView)row.findViewById(R.id.prudctName);
holder.productAmount=(TextView)row.findViewById(R.id.productAmount);
row.setTag(holder);
}
else
{
holder = (ShopingListItemHolder)row.getTag();
}
ShopingListItem item = items[position];
String amount = item.procuctAmount;
String name = item.productName;
TextView v = holder.productAmount;
TextView vv = holder.productName;
holder.productAmount.setText(amount);
holder.productName.setText(name);
return row;
}
static class ShopingListItemHolder
{
TextView productName;
TextView productAmount;
}
}
Here is the main activity:
public class ShopingListActivity extends Activity
{
private ListView listView1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shoping_list_screen);
//fill list with temp data
ShopingListItem[] items = fillData();
ShopingListItemAdapter adapter = new ShopingListItemAdapter(this, R.layout.listview_item_row, items);
listView1 = (ListView)findViewById(R.id.shoping_list);
View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);
listView1.addHeaderView(header);
listView1.setAdapter(adapter);
}
private ShopingListItem[] fillData()
{
ShopingListItem[] items = new ShopingListItem[]
{
new ShopingListItem("Bamba", "2"),
new ShopingListItem("Bisli", "12"),
new ShopingListItem("Shoko", "3"),
new ShopingListItem("Yello Cheese", "2"),
new ShopingListItem("Marak", "7"),
new ShopingListItem("Cola", "2"),
new ShopingListItem("Orez", "3"),
new ShopingListItem("Kaki", "9"),
new ShopingListItem("Battery", "1"),
new ShopingListItem("Bla", "1"),
new ShopingListItem("Bla bla", "100"),
new ShopingListItem("bbb", "200"),
new ShopingListItem("Red", "2"),
};
return items;
}
}
The result of the code is a list but with only one item (the name) the amount isnt add'd
Can anyone find the problem?
Your row layout's first TextView fills the entire row, pushing the second TextView off of the screen. You need to change your row layout. Either use wrap_content:
<TextView android:id="#+id/prudctName"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
... />
Or you can incorporate layout_weight.

Adding Custom Header to List Fragment in Android

I am trying to add a custom header that isnt clickable but will have a checkbox that will "check all" checkboxes under it.
This is my List Fragment
public class AssesmentListFragment extends ListFragment {
private static String BUNDLE_KEY_APPLICATION = "LIST_ITEM";
FastAssesmentListAdapter adapter;
View listHeader;
public AssesmentListFragment() {}
public AssesmentListFragment(Data[] data) {
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Data[] assestments = {new Data("Assesment ID","Name", "Date"), new Data("123456", "Assestment 2", "9/12/12"),
new Data("345672", "Assesment 3", "9/13/12"), new Data("566893", "Assesment 4", "9/14/12")};
//This is the part that makes the app crash
View header = getActivity().getLayoutInflater().inflate(R.layout.list_adapter_assesments, null);
ListView listView = getListView();
listView.addHeaderView(header);
adapter = new FastAssesmentListAdapter(getActivity(), assestments);
setListAdapter(adapter);
updateList(assestments);
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
private void updateList(Data[] assestments) {
// NOTE: addAll is not being used to support pre-honeycomb devices
synchronized(adapter) {
adapter.clear();
adapter.addAll(assestments);
adapter.notifyDataSetChanged();
}
}
#Override
public void onListItemClick(ListView parentView, View selectedItemView, int position, long id) {
String model = (String) parentView.getItemAtPosition(position);
((FacilityActivity) getActivity()).onItemSelected(model);
}
#Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
//outState.putInt("curChoice", mCurCheckPosition);
}
}
This is the layout I am trying to use for header
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="25dp"
android:paddingRight="10dp"
android:orientation="horizontal">
<TextView android:id="#+id/adapter_header_textview_column1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:textColor="#color/defaultTextColor"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="28sp"
android:text="Assesment ID" />
<TextView android:id="#+id/adapter_header_textview_column2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:textColor="#color/defaultTextColor"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="28sp"
android:text="Name" />
<TextView android:id="#+id/adapter_header_textview_column3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:textColor="#color/defaultTextColor"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="28sp"
android:text="Date"/>
<CheckBox
android:id="#+id/header_check_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:color="#color/defaultTextColor"
android:layout_weight=".5"
android:gravity="center" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:background="#color/BPGreenColor" />
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Then this is the array adapter I am using:
public class FastAssesmentListAdapter extends ArrayAdapter<Data> {
private static int LAYOUT_ID = R.layout.list_adapter_with_checkbox_three_column;
private final Data[] assesments;
private final Context context;
LinearLayout listHeader;
static class ViewHolder {
protected TextView column1;
protected TextView column2;
protected TextView column3;
protected CheckBox checkbox;
}
public FastAssesmentListAdapter(Context context, Data[] assesments) {
super(context, LAYOUT_ID, assesments);
this.context = context;
this.assesments = assesments;
}
//ListFragment and array adapter will automatically call this over and over to auto populate the list
#Override
public View getView(int position, View convertView, ViewGroup parent) {
final Data item = getItem(position);
// Formulate row view (create if it does not exist yet)
View view = convertView;
if(view == null) {
LayoutInflater inflater = ((Activity) getContext()).getLayoutInflater();
view = inflater.inflate(LAYOUT_ID, null);
final ViewHolder viewHolder = new ViewHolder();
viewHolder.column1 = (TextView) view.findViewById(R.id.adapter_textview_column1);
viewHolder.column2 = (TextView) view.findViewById(R.id.adapter_textview_column2);
viewHolder.column3 = (TextView) view.findViewById(R.id.adapter_textview_column3);
viewHolder.checkbox = (CheckBox) view.findViewById(R.id.check_box);
view.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(getContext(), "Clicked",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getContext(), FacilityActivity.class);
getContext().startActivity(intent);
}
});
if(viewHolder.checkbox != null) {
viewHolder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if(isChecked) {
item.setSelected(isChecked);
Toast.makeText(getContext(), "Checked",
Toast.LENGTH_SHORT).show();
}
}
});
}
view.setTag(viewHolder);
viewHolder.checkbox.setTag(position);
}
ViewHolder viewHolder = (ViewHolder) view.getTag();
viewHolder.checkbox.setTag(position);
viewHolder.column1.setText(item.getColumn1());
viewHolder.column2.setText(item.getColumn2());
viewHolder.column3.setText(item.getColumn3());
viewHolder.checkbox.setChecked(item.isSelected());
return view;
}
}
on a side note, the onlistitemclicked in the fragment doesnt work, i have to set a listener in the adapter and then it works. any ideas on that? but mainly I need to figure out how to use a custom header and custom rows in the list view. Here is the layout for the rows
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="25dp"
android:paddingRight="10dp"
android:orientation="horizontal">
<TextView android:id="#+id/adapter_textview_column1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<TextView android:id="#+id/adapter_textview_column2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<TextView android:id="#+id/adapter_textview_column3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<CheckBox
android:id="#+id/check_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:gravity="center" />
</LinearLayout>

Categories

Resources