我正在尝试在我的笑话应用程序中集成一个“下一步”按钮。我在 textView.setText( message [currentSelectedJoke]); 上收到错误消息 我知道这个错误意味着“消息”是一个字符串,但它需要一个数组。我明白这个问题。我的问题是,我该如何解决这个问题?非常感谢!
[我所有的笑话都在我的字符串中] 我的代码:
public class DisplayMessageActivity extends Activity {
Button next;
int currentSelectedJoke =0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
textView.setText(message);
textView.setTextColor(Color.BLACK);
textView.setTextSize(26);
textView.setTypeface(berlin);
///INPUT THIS FOR SOLID COLOR ///textView.setBackgroundColor(Color.MAGENTA);
textView.setBackgroundResource(R.drawable.back);
// Set the text view as the activity layout
setContentView(textView);
textView.setText(message[currentSelectedJoke]);
next=(Button)findViewById(R.id.next);
next.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
currentSelectedJoke++;
if(currentSelectedJoke == 5){
currentSelectedJoke =0;}
textView.setText(message[currentSelectedJoke]);
}
});