开发者

How to display Textview for a array item

I'm very new to android development. Hopefully you all can help me. I'm doing a modified version of asqlmanager from sourceforge. In the code, it can only display 1 data in toast at a time. However, I want to display more than one piece of data at a time. The data is something like name, identification no., age. Whenever the user clicks at the row, it will display name, identification no., age in the toast.

the code as copied is as below:-

private void appendRows(TableLayout table, String[][] data) {
    if (data == null开发者_高级运维)
        return;
    int rowSize=data.length;
    int colSize=(data.length>0)?data[0].length:0;
    for(int i=0; i<rowSize; i++){
        TableRow row = new TableRow(this);
        row.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
              // button 1 was clicked!
             Utils.logD("OnClick: " + v.getId());
           }
          });

        if (i%2 == 1)
            row.setBackgroundColor(Color.BLUE);
        for(int j=0; j<colSize; j++){
            TextView c = new TextView(this);
            c.setText(data[i][j]);
            c.setPadding(3, 3, 11, 11);
                        if (j%2 == 1)
            //                  if (i%2 == 1)
            //                      c.setBackgroundColor(Color.BLUE);
            //                  else
                                c.setBackgroundColor(Color.LTGRAY & Color.MAGENTA);
            c.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                  // button 1 was clicked!
                 Utils.logD("OnClick: " + v.getId());
                 String text = (String)((TextView)v).getText();
                 EditText Displayname;

                 Displayname=(EditText)findViewById(R.id.SQLStm);  
                 Displayname.setText(text);

                 Utils.toastMsg(_cont, "Text copied to clip board" + Displayname.getText()+ v.getId());
               }
              });
            row.addView(c);
        }
        table.addView(row, new TableLayout.LayoutParams());
    }
}

end of the code

Thank you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜