Template ROW using xml and api

by Raja Nagendra Kumar » Sat, 02 May 2009 22:54:46 GMT


Sponsored Links
 Hi,

We have a table which may have infinite rows. Would it be possible to
create row by using the xml template say

<TableRow>
            <EditText android:id="@+id/tbRelation"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:singleLine="true"
                      android:scrollHorizontally="true"
                      android:textSize="20sp"/>
            <Button android:id="@+id/bRelationQuery"
                    style="?android:attr/buttonStyleSmall"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/blQuery"/>
        </TableRow>


some thing similar to clone of existing row but with different id's
etc.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
--~--~---------~--~----~------------~-------~--~----~



Template ROW using xml and api

by Mark Murphy » Sun, 03 May 2009 02:29:42 GMT


 


Unless you have a device with infinite RAM, your table will have finite
rows.


Yes and no.

Yes, you should be able to inflate an XML file for a TableRow and use
addView() or something to append it to a TableLayout.

No, by default, each inflated row's elements will have the same IDs as
those in every other row. You would need to call setId() on each View
that needs its own ID, supplying some unique value.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Warescription: Three Android Books, Plus Updates, $35/Year

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Template ROW using xml and api

by Romain Guy » Sun, 03 May 2009 03:12:56 GMT


 A table with an "infinite" number of rows would be better implemented
as a ListView.







-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~



Template ROW using xml and api

by Raja Nagendra Kumar » Mon, 04 May 2009 14:40:12 GMT


 Hi Mark,

Thank you for details.. In the interest of others these are the code
level details we have done..

1. We have One main xml with tablelayout
2. Another  layout xml with table row specification

We every time we need to add a new row to the table, we inflate the
row xml and and find the id's, add the respective listeners.. detatch
the row from the inflated overall view and add to first views table.
Code for this is below.

addRow()
{
TableLayout tl = (TableLayout) getActivity().findViewById(R.id.table);

        LayoutInflater inflater = (LayoutInflater) (getActivity
()).getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout v = (LinearLayout) inflater.inflate
(R.layout.dial_relation_infate_row,
                                                         null,
                                                         false);

        TableRow lableRow = (TableRow) v.findViewById(R.id.labelRow);
        TextView lableField = (TextView) v.findViewById(R.id.labelField);
        v.removeView(lableRow);
        tl.addView(lableRow);
        labelRows.add(lableRow);

        TableRow fieldRow = (TableRow) v.findViewById(R.id.fieldRow);
        Button fieldButton = (Button) v.findViewById(R.id.fieldButton);
        fieldButton.setTag(dataRows.size());
        fieldButton.setOnClickListener(this);

        v.removeView(fieldRow);
        tl.addView(fieldRow);
}

Android power is in this approach to writ powerful ui with ease.

Mark, one observation regarding the id's that different rows coudl
have the same id and one could get row specific component could be
found by asking the view to find the component. This has made us not
to change the id's too.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. is possible mapview and list exist in same activity

Note that you do not need to use ListActivity to use ListView, while
(AFAIK) you do need MapActivity to use MapView.





-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



--~--~---------~--~----~------------~-------~--~----~

2. How to reorder activiity in the history stack manually?

How to reorder activiity in the history stack manually instead of using
intent flags?

Thanks in advance for the answer.

--~--~---------~--~----~------------~-------~--~----~

3. onStart() not called when a service is restarted after, being killed?

4. how to display icon in SimpleCursorAdapter?

5. audio record with latest acoustics alsa

6. Several TabHosts?

7. how to display icon in SimpleCursorAdapter?