hallo nochmals,
ich habe das jetzt mit den fragmenten hinbekommen. Habe zum testen zwei fragmente mit jeweils zwei verschiedenen layout hin und her swipen können. alles schön und gut. aber sobald ich einen layout mit googlemaps nutze bekomme ich folgenden fehlermeldung:
Code
01-03 17:38:06.290: D/AndroidRuntime(7304): Shutting down VM
01-03 17:38:06.290: W/dalvikvm(7304): threadid=1: thread exiting with uncaught exception (group=0x40c6d1f8)
01-03 17:38:06.305: E/AndroidRuntime(7304): FATAL EXCEPTION: main
01-03 17:38:06.305: E/AndroidRuntime(7304): android.view.InflateException: Binary XML file line #8: Error inflating class com.google.android.maps.MapView
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-03 17:38:06.305: E/AndroidRuntime(7304): at swipe.views2.Test_Fragment.onCreateView(Test_Fragment.java:28)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.view.ViewPager.populate(ViewPager.java:1012)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.View.measure(View.java:12929)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.View.measure(View.java:12929)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.widget.LinearLayout.measureVertical(LinearLayout.java:822)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.View.measure(View.java:12929)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4703)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
01-03 17:38:06.305: E/AndroidRuntime(7304): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2257)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.View.measure(View.java:12929)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1240)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2628)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.os.Handler.dispatchMessage(Handler.java:99)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.os.Looper.loop(Looper.java:137)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.app.ActivityThread.main(ActivityThread.java:4511)
01-03 17:38:06.305: E/AndroidRuntime(7304): at java.lang.reflect.Method.invokeNative(Native Method)
01-03 17:38:06.305: E/AndroidRuntime(7304): at java.lang.reflect.Method.invoke(Method.java:511)
01-03 17:38:06.305: E/AndroidRuntime(7304): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
01-03 17:38:06.305: E/AndroidRuntime(7304): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
01-03 17:38:06.305: E/AndroidRuntime(7304): at dalvik.system.NativeStart.main(Native Method)
01-03 17:38:06.305: E/AndroidRuntime(7304): Caused by: java.lang.ClassNotFoundException: com.google.android.maps.MapView
01-03 17:38:06.305: E/AndroidRuntime(7304): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-03 17:38:06.305: E/AndroidRuntime(7304): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-03 17:38:06.305: E/AndroidRuntime(7304): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
01-03 17:38:06.305: E/AndroidRuntime(7304): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
01-03 17:38:06.305: E/AndroidRuntime(7304): ... 35 more
01-03 17:38:06.335: D/dalvikvm(7304): GC_CONCURRENT freed 206K, 3% free 9385K/9671K, paused 2ms+1ms
Alles anzeigen
meine klassen sehen so aus:
Code
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.NavUtils;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class MainActivity extends FragmentActivity {
SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adapter that will return a fragment for each of the three
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Alles anzeigen
Java
package swipe.views2;
import java.util.List;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
if (position < 2) {
Test_Fragment f = new Test_Fragment(position);
return f;
}
else {
Test_Fragment f = new Test_Fragment(position);
return f;
}
}
@Override
public int getCount() {
// Show 3 total pages.
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "Fragment A";
case 1:
return "Fragment B";
// case 2:
// return getString(R.string.title_section3).toUpperCase();
}
return null;
}
}
Alles anzeigen
Code
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class Test_Fragment extends Fragment {
private int fragmentNR;
public Test_Fragment(int nr) {
this.fragmentNR = nr;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = new View(getActivity());
if (fragmentNR == 0)
v = inflater.inflate(R.layout.fragment_music, container, false);
else if (fragmentNR == 1)
v = inflater.inflate(R.layout.fragment_map, container, false);
return v;
}
}
Alles anzeigen
ich bin am verzweifeln und bitte um jede mögliche hilfe.