Table Layout and Button click event

This is my xml table layout file:

ID  Car No  Timein      Timeout     Charge    Print

1   AA-123  9:00        12:00       1000      btnprint

2   BB-123  10:00       1:00        1000      btnprint

3   CC-123  10:00       1:00        1000      btnprint 

On a print button click I want to get the row data and send it role by role to another activity.

How to get the table row values and button click parameter?

Answers


If the TextViews(I think Car No, TimeIn etc are all TextViews, right?) and the print Button are wrapped by a TableRow then it's pretty simple to get the data:

    printBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TableRow tr = (TableRow) v.getParent();
            TextView carNumber = (TextView) tr.findViewById(R.id.the_id_ofTheCarNumberTextView);
                            String carNumberText = carNumber.getText().toString();   
            TextView timeIn = (TextView) tr.findViewById(R.id.the_id_ofTheTimeInTextView);
                            String timeInText = carNumber.getText().toString();
            TextView timeOut = (TextView) tr.findViewById(R.id.the_id_ofTheTimeOutTextView);
                            String timeOutText = carNumber.getText().toString();
            // etc get the rest of the fields
            // put the data in the intent and start send it to the new
            // activity
        }
    });

Depending on the number of rows, you may want to look at the ListView widget.


Need Your Help

Android - Convert JSON to UFT-8

android json utf-8

I need help converting JSON response to UTF-8.

Why do I need to explicitly output the HTTP header for IIS but not Apache?

perl apache http iis cgi

I am trying to set up apache instead of IIS because IIS needlessly crashes all the time, and it would be nice to be able to have my own checkout of the source instead of all of us editing a common

Navigation causes an out of memory exception

c# windows-phone-7

I am working on a windows phone app (really big one) that has at least 60 different pages, on some navigation i am getting a "out of memory error". This is usually happening on the last pages (on the