0

当我尝试从 onCreate 调用函数时,应用程序停止工作。我要做的就是在活动加载时更改 textview 中的文本。帮助?

public class BellSchedules extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bell_schedules);
    BellSch(null);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.bell_schedules, menu);
    return true;
}

public void BellSch(View view)
{
    TextView bells = (TextView) findViewById(R.id.textView1);
    int date = (Calendar.DAY_OF_WEEK);
    String realDate = getString(date);
    //bells.setText(realDate);
    bells.setText("huehuehuehuehue");
}
4

2 回答 2

1

getString方法的参数是 a resId,它需要指向您的资源 ID 之一。参考这里: http: //developer.android.com/reference/android/content/Context.html#getString(int)

试试这个:

String realDate = ""+date;
于 2013-07-09T23:46:15.593 回答
0

你需要把

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // do your work
    return true;
}
于 2013-07-09T23:47:30.223 回答