Nie znaleziono widoku dla identyfikatora 0x7f090005
Zaczynam budować prostą aplikację na Androida, więc kiedy naciskam przycisk wideo, wywołuje fragment zawierający odtwarzacz wideo, ale zawsze otrzymuję: Nie znaleziono widoku dla identyfikatora 0x7f090005 ...
Zastanawiam się, czy dasz mi rękę, zastanawiając się, co jest nie tak w kodzie, który piszę.
Oto mój plik MainActivity.java:
public class MainActivity extends Activity { private Button mVideoButton; Fragment fragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); mVideoButton = (Button)findViewById(R.id.videoButton); // Video Button mVideoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); FragmentVideo sf = new FragmentVideo(); ft.add(R.id.fragmentVideo, sf); ft.commit(); } }); } }
Następnie mam swój plik main_activity.xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activityStart" >
<ImageView
android:src="@drawable/armstrong_on_moon"
android:contentDescription="@string/description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerInside"
android:layout_weight="1" />
<TableRow
android:gravity="center|bottom"
android:layout_weight="0">
<Button
android:id="@+id/videoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/video" />
</TableRow>
Następnie moja klasa FragmentVideo.java:
public class FragmentVideo extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState ){
View v = inflater.inflate(R.layout.fragment_video, parent, false);
return v;
}
}
I wreszcie fragment_video.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/fragmentVideo" >
<VideoView
android:id="@+id/video"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" />
<ProgressBar
android:id="@+id/prog"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center" />
</LinearLayout>
Daj mi znać, jeśli robię coś złego lub jeśli czegoś brakuje, widzę, gdzie leży problem.
Bardzo dziękuję za pomoc z góry.
EGMWEB