次/前のボタンとコピーボタンを備えた見積もりアプリを開発しています。
これはコードです:
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;
}
});
}
前の文字列を textView に表示するには、「前の」ボタンの onClick コードが必要です。