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

WPF textbox text file

c# wpf xaml

im building an WPF application in which i have a textbox, but the problem is that this textbox needs to get the contents of a file as text, only the txt file keeps getting written too.

MySQL IS IN() AS A RESULT

mysql sql

How do I display in SELECT results 1 if a variable exits in other table and 0 if not? Is it possible or I have to JOIN? And in case it is possible only by JOIN, what if my SELECT is really complica...

Upload Image with Facebook status, WP8

c# facebook windows-phone-8

I am unable to send the facebook status with image. Found the code but it throws the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.