我正在嘗試在我的笑話應用中整合「下一步」按鈕。我得到textView.setText錯誤(消息 [currentSelectedJoke]); 我知道這個錯誤意味着「消息」是一個字符串,但它期望一個數組。我理解這個問題。我的問題是,我該如何解決這個問題? 非常感謝!表達式的類型必須是數組類型,但它解析爲一個字符串?
[ALL我的笑話都在裏面我的琴絃] 我的代碼:
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]);
}
});
你在哪裏聲明'message' –
textview沒有被初始化。 – Raghunandan
問題在於我有104個笑話。如果我能夠告訴它接受字符串,那將會容易得多。感謝您的提示,但! – Tashad