你要的是这样的效果吗:
public class TestActivity extends Activity {
private TextView mTestText = null;
private String[] mTestString = null;
private int mclick = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mTestText = (TextView)findViewById(R.id.testText);
mTestText.setOnClickListener(mOnClick);
mTestString = new String[]{"text1" , "text2" , "text3" , "text4" , "text5"};
mTestText.setText(mTestString[0]);
}
OnClickListener mOnClick = new OnClickListener() {
@Override
public void onClick(View arg0) {
if(mclick < 5){
mTestText.setText(mTestString[mclick]);
mclick ++;
}else{
mclick = 0;
mTestText.setText(mTestString[mclick]);
mclick ++;
}
}
};
}
你可以写一个for循环么,for(int i = 0;i < 数组名.length;i++){
功能
}
给它增加一个点击事件