我不能找到什麼錯我的代碼我得到解決不了或不上findViewById的字段。不能得到解決或無法在現場findViewById
的問題行是:
playSeekBar = (ProgressBar) findViewById(R.id.progressBar1);
buttonPlay = (Button) findViewById(R.id.buttonPlay);
buttonStopPlay = (Button) findViewById(R.id.buttonStopPlay);
我的XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar android:id="@+id/progressBar1" android:layout_width="wrap_content" android:layout_height="wrap_content"></ProgressBar>
<Button android:text="Button" android:id="@+id/buttonPlay" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Button" android:id="@+id/buttonStopPlay" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
我的代碼是:
public class radioActivite extends Activity implements OnClickListener {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.radio_xml);
initializeUIElements();
initializeMediaPlayer();
}
private void initializeUIElements() {
playSeekBar = (ProgressBar) findViewById(R.id.progressBar1);
playSeekBar.setMax(100);
playSeekBar.setVisibility(View.INVISIBLE);
buttonPlay = (Button) findViewById(R.id.buttonPlay);
buttonPlay.setOnClickListener(this);
buttonStopPlay = (Button) findViewById(R.id.buttonStopPlay);
試圖清理代碼,但沒有幫助我。 感謝您的幫助!
你可以使用從LogCat獲取的堆棧跟蹤來更新問題嗎? –