이 포럼에서 질문하는 비슷한 질문의 수로 판단 할 때 일반적인 오류가있는 것으로 확인되었지만 이에 대한 답을 찾지 못했습니다.조각으로 TabActivity 바꾸기 : 클래스 조각을 부 풀리는 오류가 발생했습니다.
나는 더 이상 사용되지 않는 tabActivity를 대체하기 위해 조각을 사용하려고합니다.
<?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" >
<fragment
android:name="fr.partisocialite.psa.activity.TabsFragment"
android:id="@+id/tabs_fragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
public class MediaActivity extends FragmentActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.psa_media);
}
가 나는 또한 안드로이드 교체 시도했다 : 여기
클래스
이름 것은 내 로그 캣입니다 :02-09 10:07:48.738: E/AndroidRuntime(1713): FATAL EXCEPTION: main
> 02-09 10:07:48.738: E/AndroidRuntime(1713):
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{fr.partisocialiste.psa/fr.partisocialiste.psa.activity.MediaActivity}:
> android.view.InflateException: Binary XML file line #7: Error
> inflating class fragment 02-09 10:07:48.738: E/AndroidRuntime(1713):
> at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.app.ActivityThread.startActivityNow(ActivityThread.java:1487)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.widget.TabHost.setCurrentTab(TabHost.java:326) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:456)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.View.performClick(View.java:2485) 02-09 10:07:48.738:
> E/AndroidRuntime(1713): at
> android.view.View$PerformClick.run(View.java:9080) 02-09 10:07:48.738:
> E/AndroidRuntime(1713): at
> android.os.Handler.handleCallback(Handler.java:587) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.os.Handler.dispatchMessage(Handler.java:92) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.os.Looper.loop(Looper.java:130) 02-09 10:07:48.738:
> E/AndroidRuntime(1713): at
> android.app.ActivityThread.main(ActivityThread.java:3683) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> java.lang.reflect.Method.invokeNative(Native Method) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> java.lang.reflect.Method.invoke(Method.java:507) 02-09 10:07:48.738:
> E/AndroidRuntime(1713): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> dalvik.system.NativeStart.main(Native Method) 02-09 10:07:48.738:
> E/AndroidRuntime(1713): Caused by: android.view.InflateException:
> Binary XML file line #7: Error inflating class fragment 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.LayoutInflater.inflate(LayoutInflater.java:408) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.LayoutInflater.inflate(LayoutInflater.java:320) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.LayoutInflater.inflate(LayoutInflater.java:276) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.app.Activity.setContentView(Activity.java:1657) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> fr.partisocialiste.psa.activity.MediaActivity.onCreate(MediaActivity.java:14)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): ... 18 more 02-09
> 10:07:48.738: E/AndroidRuntime(1713): Caused by:
> android.support.v4.app.Fragment$InstantiationException: Unable to
> instantiate fragment fr.partisocialite.psa.activity.TabsFragment: make
> sure class name exists, is public, and has an empty constructor that
> is public 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.support.v4.app.Fragment.instantiate(Fragment.java:332) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.support.v4.app.Fragment.instantiate(Fragment.java:300) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:248)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): ... 27 more 02-09
> 10:07:48.738: E/AndroidRuntime(1713): Caused by:
> java.lang.ClassNotFoundException:
> fr.partisocialite.psa.activity.TabsFragment in loader
> dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/fr.partisocialiste.psa-1.apk]
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
> 02-09 10:07:48.738: E/AndroidRuntime(1713): at
> java.lang.ClassLoader.loadClass(ClassLoader.java:551) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> java.lang.ClassLoader.loadClass(ClassLoader.java:511) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): at
> android.support.v4.app.Fragment.instantiate(Fragment.java:322) 02-09
> 10:07:48.738: E/AndroidRuntime(1713): ... 30 more 02-09 10:07:48.804:
> I/global(1713): Loaded time zone names for en_US in 1110ms. 02-09
> 10:07:49.957: D/dalvikvm(1713): GC_CONCURRENT freed 908K, 51% free
> 3705K/7431K, external 2360K/3860K, paused 2ms+2ms 02-09 10:07:50.242:
> I/global(1713): Loaded time zone names for en_US in 1147ms. 02-09
> 10:07:50.410: D/dalvikvm(1713): GC_FOR_MALLOC freed 598K, 51% free
> 3698K/7431K, external 2360K/3860K, paused 38ms 02-09 10:07:50.574:
> D/dalvikvm(1713): GC_FOR_MALLOC freed 164K, 50% free 3779K/7431K,
> external 2360K/3860K, paused 51ms 02-09 10:07:50.593:
> D/dalvikvm(1713): GC_FOR_MALLOC freed 243K, 50% free 3773K/7431K,
> external 2360K/3860K, paused 15ms 02-09 10:07:50.609:
> D/dalvikvm(1713): GC_FOR_MALLOC freed <1K, 47% free 4010K/7431K,
> external 2360K/3860K, paused 16ms 02-09 10:07:50.699:
> D/dalvikvm(1713): GC_CONCURRENT freed 1194K, 49% free 3982K/7687K,
> external 2360K/3860K, paused 2ms+3ms
고마워, 내가 성공하지 못했습니다 내 logCat을 더 잘 보이게 만드는 것에 대해, 미안합니다. 여기
내 클래스 TabsFragment입니다< < < < <
package fr.partisocialiste.psa.activity;
import fr.partisocialiste.psa.R;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
public class TabsFragment extends Fragment implements OnTabChangeListener{
private static final String TAG = "FragmentTabs";
public static final String TAB_HOLL = "Hollande";
public static final String TAB_PS = "PS";
private View mRoot;
private TabHost mTabHost;
private int mCurrentTab;
public TabsFragment(){
super();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mRoot = inflater.inflate(R.layout.tabs_fragment, null);
mTabHost = (TabHost) mRoot.findViewById(android.R.id.tabhost);
setupTabs();
return mRoot;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setRetainInstance(true);
mTabHost.setOnTabChangedListener(this);
mTabHost.setCurrentTab(mCurrentTab);
// manually start loading hollande
updateTab(TAB_HOLL, R.id.tab_hollande);
}
private void setupTabs() {
mTabHost.setup(); // important!
mTabHost.addTab(newTab(TAB_HOLL, R.string.tab_hollande, R.id.tab_hollande));
mTabHost.addTab(newTab(TAB_PS, R.string.tab_ps, R.id.tab_ps));
}
private TabSpec newTab(String tag, int labelId, int tabContentId) {
Log.d(TAG, "buildTab(): tag=" + tag);
View indicator = LayoutInflater.from(getActivity()).inflate(
R.layout.tab,
(ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
((TextView) indicator.findViewById(R.id.text)).setText(labelId);
TabSpec tabSpec = mTabHost.newTabSpec(tag);
tabSpec.setIndicator(indicator);
tabSpec.setContent(tabContentId);
return tabSpec;
}
@Override
public void onTabChanged(String tabId) {
if (TAB_HOLL.equals(tabId)) {
updateTab(tabId, R.id.tab_hollande);
mCurrentTab = 0;
return;
}
if (TAB_PS.equals(tabId)) {
updateTab(tabId, R.id.tab_ps);
mCurrentTab = 1;
return;
}
}
private void updateTab(String tabId, int placeholder) {
FragmentManager fm = getFragmentManager();
if (fm.findFragmentByTag(tabId) == null) {
if(TAB_HOLL.equals(tabId)){
// fm.beginTransaction()
// .replace(placeholder, new MyListFragment(tabId), tabId)
// .commit();
}
else if(TAB_PS.equals(tabId)){
// fm.beginTransaction()
// .replace(placeholder, new MyListFragment(tabId), tabId)
// .commit();
}
}
}
}
여기 API 레벨은 무엇입니까? – Ksice
호환성 라이브러리가있는 Android 2.2는 API 4 –