【发布时间】:2014-11-12 20:29:43
【问题描述】:
我需要一些帮助来在我的抽认卡应用中存储和显示文本字符串。计划是当用户点击 textView (FLASHCARD_FRONT) 时,它会切换到 FLASHCARD_BACK,并且能够在不同的抽认卡之间导航(正面+背面):
理想情况下,我希望将字符串保留在数组中,以便将来用户可以添加新字符串(卡片)并通过它们导航。
public class MainActivity extends Activity {
Button closeButton, addButton, prevButton, nextButton;
TextView question, answer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
closeButton = (Button) findViewById(R.id.closebutton);
addButton = (Button) findViewById(R.id.plusbutton);
prevButton = (Button) findViewById(R.id.prevbutton);
nextButton = (Button) findViewById(R.id.nextbutton);
question = (TextView) findViewById(R.id.fcfront_textView);
answer = (TextView) findViewById(R.id.fcfront_textView); //not linked to anywhere atm
//adicionado
nextButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "Hello TOAST test!", Toast.LENGTH_LONG).show();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void onPlusButtonClick(View view) {
}
public void onCloseButtonClick(View view) {
String close_msg = "Thanks for trying !! " ;
Toast.makeText(this, close_msg, Toast.LENGTH_SHORT).show();
}
public void onNextButtonClick(View view) {
}
public void onPrevButtonClick(View view) {
}
}
【问题讨论】:
标签: java android xml android-activity