-2

we have stored some text in an arraylist. we want to display it in a single textview,when I click the textview the next value(text) in the arraylist should be updated in the widget.

Freak
  • 6,786
  • 5
  • 36
  • 54
  • Could you post some code? What exactly is not working. This question provides some info on how to use onClick() in a widget http://stackoverflow.com/questions/9851000/change-icon-when-textview-is-clicked-in-widget – Lukas Ruge Jul 03 '13 at 08:07
  • show some efforts maybe someone can help,i think nobody would love to do your homework! – Arash GM Jul 03 '13 at 08:08
  • Where is the problem?? – Narendra Jul 03 '13 at 08:21

1 Answers1

0

If I understand what you're trying to do correctly, try this out:

public class MyActivity extends Activity {
    ArrayList<String> values = new ArrayList<String>();
    TextView myText;
    private int index;
    protected void onCreate(Bundle saved) {
         super.onCreate(saved);

         setContentView(R.layout.content_layout_id);
         index = 0;

         //example values:
         values.add("foo");
         values.add("bar");
         values.add("another value");

         myText = (TextView) findViewById(R.id.myTextId);
         //show the first value on myText
         myText.setText(values.get(index));

         myText.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 // Show next value in our text view:
                myText.setText(values.get(++index));
                //be sure to consider the ArrayList.size() so you won't try to present the 6th value in a 5 values ArrayList.
                //but this depends on your implementation.
             }
         });
     }
 }
user1555863
  • 2,567
  • 6
  • 35
  • 50