我正在开发一个具有下一个/上一个和复制按钮的报价应用程序。
这是代码:
Button btn1;
String countires[];
int i=0;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.prob2);
btn1 = (Button) findViewById(R.id.prob2_btn1);
countires = getResources().getStringArray(R.array.country);
for (String string : countires)
{
Log.i("--: VALUE :--","string = "+string);
}
btn1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
// TODO Auto-generated method stub
String country = countires[i];
btn1.setText(country);
i++;
if(i==countires.length)
i=0;
}
});
}
我需要“上一个”按钮的 onClick 代码才能在 textView 中显示上一个字符串???