- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在努力将此 fragment 添加到我的 XML 布局中。
在我的 Activity XML 布局中,我有以下内容:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical" >
<fragment
android:id="@+id/fragment_invitefriendsprogress"
android:name="tv.superawesome.club.android.ui.fragments.InviteFriendsProgressFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_invitefriendsprogress" />
</LinearLayout>
我得到一个奇怪的错误:
XML file line #205: Class is not a View android.support.v4.app.Fragment
第 205 行是:
<fragment
我错过了什么吗?
完整的 XML 布局代码供引用:
<RelativeLayout
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="@drawable/actionbar" >
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:src="@drawable/small" />
<ImageView
android:id="@+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="@drawable/starpink" />
<ImageView
android:id="@+id/man"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/star"
android:layout_marginRight="25dp"
android:layout_toLeftOf="@+id/star"
android:src="@drawable/invitepink" />
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bar"
android:layout_alignParentTop="true"
android:background="@drawable/bg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/inwrapper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="@drawable/bg"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="-10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="@color/white"
android:gravity="center|top"
android:orientation="vertical" >
<com.myapp.jimbob.android.ui.CustomTextView
android:id="@+id/inTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="18dp"
android:text="@string/intitle"
android:textSize="16sp" />
<com.myapp.jimbob.android.ui.CustomTextView
android:id="@+id/indescriptiob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="2dp"
android:text="@string/indescription"
android:textSize="12sp" />
<EditText
android:id="@+id/emailedittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/white"
android:drawablePadding="10dp"
android:ems="10"
android:hint="@string/yoemail"
android:inputType="textEmailAddress"
android:padding="10dp"
android:textSize="12sp" >
<requestFocus />
</EditText>
<Button
android:id="@+id/addbutton"
style="@style/OButton"
android:layout_height="30dp"
android:layout_marginTop="10dp"
android:text="@string/addinvite"
android:textSize="14sp" />
<com.myapp.jimbob.android.ui.CustomTextView
android:id="@+id/mailsdescriptiom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="10dp"
android:text="@string/emailsofar"
android:textSize="12sp" />
<ScrollView
android:id="@+id/emailsscrollview"
android:layout_width="match_parent"
android:layout_height="92dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginTop="8dp" >
<LinearLayout
android:id="@+id/emailslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_gray"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/emailrow"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.myapp.jimbob.android.ui.CustomTextView
android:id="@+id/emailaddresstextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:paddingLeft="15dp"
android:text="PlaceHolder"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="12sp" />
<ImageView
android:id="@+id/cancelimageview"
android:layout_width="15dp"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:src="@drawable/abs_clear" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/sendbutton"
style="@style/OButton"
android:layout_height="30dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:text="@string/mfriends"
android:textSize="14sp" />
<ProgressBar
android:id="@+id/friendindicator"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<Button
android:id="@+id/inviteprogressbutton"
style="@style/OrangeSmallButton"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignRight="@+id/linearLayout1"
android:layout_below="@+id/linearLayout1"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="abc"
android:textSize="10sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical" >
<fragment
android:id="@+id/fragment_myfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.myapp.jimbob.android.ui.fragments.MyFragment"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<include layout="@layout/layout_toast" />
这里还有 Fragment 类:
public class MyFragment extends SherlockFragment {
private CustomTextView mTitle;
private CustomTextView mDescription;
private CustomTextView mStar5Description;
private CustomTextView mStar10Description;
private ImageView mStar1, mStar2, mStar3, mStar4, mStar5, mStar6, mStar7,
mStar8, mStar9, mStar10;
private Button mFriends5Button;
private Button mFriends10Button;
private Button mInviteFriendsButton;
private int inviteCount;
private View mRootView = null;
private ProgressBar mProgressBar;
private void setAlphaForView(View v, float alpha) {
AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
animation.setDuration(0);
animation.setFillAfter(true);
v.startAnimation(animation);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (mRootView != null) {
ViewGroup parent = (ViewGroup) mRootView.getParent();
if (parent != null)
parent.removeView(mRootView);
}
try {
mRootView = inflater
.inflate(R.layout.fragment_invitefriendsprogress, container, false);
} catch (InflateException e) {
/* map is already there, just return view as it is */
}
mTitle = (CustomTextView) mRootView.findViewById(R.id.progressTitle);
mDescription = (CustomTextView) mRootView.findViewById(R.id.progressDescription);
mStar5Description = (CustomTextView) mRootView.findViewById(R.id.progress5starDescription);
mStar10Description = (CustomTextView) mRootView.findViewById(R.id.progress10StarDescription);
mStar1 = (ImageView) mRootView.findViewById(R.id.invitestar1);
mStar2 = (ImageView) mRootView.findViewById(R.id.invitestar2);
mStar3 = (ImageView) mRootView.findViewById(R.id.invitestar3);
mStar4 = (ImageView) mRootView.findViewById(R.id.invitestar4);
mStar5 = (ImageView) mRootView.findViewById(R.id.invitestar5);
mStar6 = (ImageView) mRootView.findViewById(R.id.invitestar6);
mStar7 = (ImageView) mRootView.findViewById(R.id.invitestar7);
mStar8 = (ImageView) mRootView.findViewById(R.id.invitestar8);
mStar9 = (ImageView) mRootView.findViewById(R.id.invitestar9);
mStar10 = (ImageView) mRootView.findViewById(R.id.invitestar10);
mFriends5Button = (Button) mRootView.findViewById(R.id.guarantee5button);
mFriends10Button = (Button) mRootView.findViewById(R.id.guarantee10button);
mProgressBar = (ProgressBar) mRootView.findViewById(R.id.invitesProgressBar);
inviteCount = BoxStatusCache.getInstance(mRootView.getContext().getApplicationContext()).inviteCount;
if (MyTheme.getTheme(mRootView.getContext()) == MyTheme.BOA) {
mRootView.findViewById(R.id.bglayout).setBackgroundResource(
R.drawable.bgawesome);
mTitle.setCustom(false);
mTitle.setCustom(true, CustomTextView.BOATITLEFONT);
mTitle.setTextColor(getResources().getColor(R.color.purple));
mDescription.setCustom(true, CustomTextView.BOADESCFONT);
mStar5Description.setCustom(true, CustomTextView.BOADESCFONT);
mStar10Description.setCustom(true, CustomTextView.BOADESCFONT);
mFriends5Button.setTypeface(CustomTypeface.getTypefaceBOADesc(mRootView.getContext().getApplicationContext()));
mFriends10Button.setTypeface(CustomTypeface.getTypefaceBOADesc(mRootView.getContext().getApplicationContext()));
} else {
mRootView.findViewById(R.id.bglayout).setBackgroundResource(
R.drawable.bg);
mTitle.setCustom(true);
mFriends5Button.setBackgroundResource(R.drawable.pinksmallbutton);
mFriends10Button.setBackgroundResource(R.drawable.pinksmallbutton);
mTitle.setCustom(true, CustomTextView.TITLEFONT);
mTitle.setTextColor(getResources().getColor(R.color.pink));
mDescription.setCustom(true, CustomTextView.DESCFONT);
mStar5Description.setCustom(true, CustomTextView.DESCFONT);
mStar10Description.setCustom(true, CustomTextView.DESCFONT);
mFriends5Button.setTypeface(CustomTypeface.getTypefaceDesc(mRootView.getContext().getApplicationContext()));
mFriends10Button.setTypeface(CustomTypeface.getTypefaceDesc(mRootView.getContext().getApplicationContext()));
}
mStar1.setImageResource(R.drawable.notinvited);
mStar2.setImageResource(R.drawable.notinvited);
mStar3.setImageResource(R.drawable.notinvited);
mStar4.setImageResource(R.drawable.notinvited);
mStar5.setImageResource(R.drawable.notinvited);
mStar6.setImageResource(R.drawable.notinvited);
mStar7.setImageResource(R.drawable.notinvited);
mStar8.setImageResource(R.drawable.notinvited);
mStar9.setImageResource(R.drawable.notinvited);
mStar10.setImageResource(R.drawable.notinvited);
// Uncomment this after finish debugging
if (inviteCount < 10) {
setAlphaForView(mFriends10Button, 0.5f);
mFriends10Button.setClickable(false);
if (inviteCount < 5) {
setAlphaForView(mFriends5Button, 0.5f);
mFriends5Button.setClickable(false);
}
}
final Context context = mRootView.getContext();
mFriends5Button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mProgressBar.setVisibility(View.VISIBLE);
setAlphaForView(mFriends5Button, 0.5f);
// TODO Auto-generated method stub
new AsyncTask<Void, Void, JSONObject>() {
@Override
protected JSONObject doInBackground(Void... params) {
try {
HashMap<Object, Object> data = new HashMap<Object, Object>();
if (MyTheme.getTheme(context) == MyTheme.TWO) {
data.put("site", 1);
} else {
data.put("site", 0);
}
data.put("invite_amount", 5);
LogUtils.log("redeem data: " + data.toString());
String response = HttpRequestController
.getInstance().doRequest(
ApiUrls.REDEEM_INVITATION, data,
Method.POST, MainActivity.token);
return new JSONObject(response);
} catch (Exception e) {
e.printStackTrace();
mProgressBar.setVisibility(View.INVISIBLE);
setAlphaForView(mFriends5Button, 1.0f);
return null;
}
}
@Override
protected void onPostExecute(JSONObject result) {
mProgressBar.setVisibility(View.INVISIBLE);
setAlphaForView(mFriends5Button, 1.0f);
try {
if (result.getBoolean("success")) {
makeGoodToastAndEatIt();
LogUtils.log("result MyActivity: "
+ result.toString());
getActivity().setResult(getActivity().RESULT_OK);
SyncUtils.forceUpdateProfile();
} else {
LogUtils.log("error_msg: " + result.toString());
if (result.getString("error_msg").contains(
"Not enough")) {
ToastAnimationUtils
.setUpAnimations(
getActivity(),
"Not enough invitations. Invite some more friends and try again!",
false);
} else {
ToastAnimationUtils
.setUpAnimations(
getActivity(),
"Try again later.",
false);
}
}
} catch (Exception e) {
e.printStackTrace();
ToastAnimationUtils
.setUpAnimations(
getActivity(),
"Try again later. ",
false);
}
}
}.execute();
}
});
mFriends10Button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mProgressBar.setVisibility(View.VISIBLE);
setAlphaForView(mFriends10Button, 0.5f);
// TODO Auto-generated method stub
new AsyncTask<Void, Void, JSONObject>() {
@Override
protected JSONObject doInBackground(Void... params) {
try {
HashMap<Object, Object> data = new HashMap<Object, Object>();
if (MyTheme.getTheme(context) == MyTheme.BOA) {
data.put("site", 1);
} else {
data.put("site", 0);
}
data.put("invite_amount", 10);
LogUtils.log("redeem data: " + data.toString());
String response = HttpRequestController
.getInstance().doRequest(
ApiUrls.REDEEM_INVITATION, data,
Method.POST, MainActivity.token);
return new JSONObject(response);
} catch (Exception e) {
e.printStackTrace();
mProgressBar.setVisibility(View.INVISIBLE);
setAlphaForView(mFriends10Button, 1.0f);
return null;
}
}
@Override
protected void onPostExecute(JSONObject result) {
mProgressBar.setVisibility(View.INVISIBLE);
setAlphaForView(mFriends10Button, 1.0f);
try {
if (result.getBoolean("success")) {
makeMegaGoodToastAndEatIt();
LogUtils.log("result MyActivity: "
+ result.toString());
getActivity().setResult(MainActivity.RESULT_OK);
SyncUtils.forceUpdateProfile();
} else {
if (result.getString("error_msg").contains(
"Not enough")) {
ToastAnimationUtils
.setUpAnimations(
getActivity(),
"Not enough invitations. Invite some more friends and try again!",
false);
} else {
ToastAnimationUtils
.setUpAnimations(
getActivity(),
" Try again later.",
false);
}
}
} catch (Exception e) {
e.printStackTrace();
ToastAnimationUtils
.setUpAnimations(
getActivity(),
"Try again later. ",
false);
}
}
}.execute();
}
});
LogUtils.log("inviteCount: " + inviteCount);
if (inviteCount > 0 && MyTheme.getTheme(getActivity()) == MyTheme.TWO) {
mStar1.setImageResource(R.drawable.invited);
if (inviteCount > 1) {
mStar2.setImageResource(R.drawable.invited);
if (inviteCount > 2) {
mStar3.setImageResource(R.drawable.invited);
if (inviteCount > 3) {
mStar4.setImageResource(R.drawable.invited);
if (inviteCount > 4) {
mStar5.setImageResource(R.drawable.invited);
if (inviteCount > 5) {
mStar6.setImageResource(R.drawable.invited);
if (inviteCount > 6) {
mStar7.setImageResource(R.drawable.invited);
if (inviteCount > 7) {
mStar8.setImageResource(R.drawable.invited);
if (inviteCount > 8) {
mStar9.setImageResource(R.drawable.invited);
if (inviteCount > 9) {
mStar10.setImageResource(R.drawable.invited);
}
}
}
}
}
}
}
}
}
} else if (inviteCount > 0
&& MyTheme.getTheme(getActivity()) == MyTheme.ONE) {
mStar1.setImageResource(R.drawable.invited);
if (inviteCount > 1) {
mStar2.setImageResource(R.drawable.invited);
if (inviteCount > 2) {
mStar3.setImageResource(R.drawable.invited);
if (inviteCount > 3) {
mStar4.setImageResource(R.drawable.invited);
if (inviteCount > 4) {
mStar5.setImageResource(R.drawable.invited);
if (inviteCount > 5) {
mStar6.setImageResource(R.drawable.invited);
if (inviteCount > 6) {
mStar7.setImageResource(R.drawable.invited);
if (inviteCount > 7) {
mStar8.setImageResource(R.drawable.invited);
if (inviteCount > 8) {
mStar9.setImageResource(R.drawable.invited);
if (inviteCount > 9) {
mStar10.setImageResource(R.drawable.invited);
}
}
}
}
}
}
}
}
}
}
return mRootView;
}
}
完整的日志:
01-03 13:36:18.840: E/ACRA(6144): ACRA caught a RuntimeException exception for com.myapp.jimbob.android. Building report.
01-03 13:36:19.252: E/AndroidRuntime(6144): FATAL EXCEPTION: main
01-03 13:36:19.252: E/AndroidRuntime(6144): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.jimbob.android/com.myapp.jimbob.android.ui.activities.MyActivity}: android.view.InflateException: Binary XML file line #205: Error inflating class fragment
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.os.Handler.dispatchMessage(Handler.java:99)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.os.Looper.loop(Looper.java:137)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.ActivityThread.main(ActivityThread.java:5103)
01-03 13:36:19.252: E/AndroidRuntime(6144): at java.lang.reflect.Method.invokeNative(Native Method)
01-03 13:36:19.252: E/AndroidRuntime(6144): at java.lang.reflect.Method.invoke(Method.java:525)
01-03 13:36:19.252: E/AndroidRuntime(6144): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
01-03 13:36:19.252: E/AndroidRuntime(6144): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-03 13:36:19.252: E/AndroidRuntime(6144): at dalvik.system.NativeStart.main(Native Method)
01-03 13:36:19.252: E/AndroidRuntime(6144): Caused by: android.view.InflateException: Binary XML file line #205: Error inflating class fragment
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
01-03 13:36:19.252: E/AndroidRuntime(6144): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
01-03 13:36:19.252: E/AndroidRuntime(6144): at com.actionbarsherlock.internal.ActionBarSherlockNative.setContentView(ActionBarSherlockNative.java:133)
01-03 13:36:19.252: E/AndroidRuntime(6144): at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
01-03 13:36:19.252: E/AndroidRuntime(6144): at com.myapp.jimbob.android.ui.activities.MyActivity.onCreate(MyActivity.java:75)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.Activity.performCreate(Activity.java:5133)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
01-03 13:36:19.252: E/AndroidRuntime(6144): ... 11 more
01-03 13:36:19.252: E/AndroidRuntime(6144): Caused by: java.lang.ClassCastException: com.myapp.jimbob.android.ui.fragments.MyFragment cannot be cast to android.app.Fragment
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.Fragment.instantiate(Fragment.java:585)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.Fragment.instantiate(Fragment.java:560)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.app.Activity.onCreateView(Activity.java:4738)
01-03 13:36:19.252: E/AndroidRuntime(6144): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
01-03 13:36:19.252: E/AndroidRuntime(6144): ... 25 more
最佳答案
而不是这个...
<android.support.v4.app.Fragment
android:id="@+id/fragment_myfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.myapp.jimbob.android.ui.fragments.MyFragment"
tools:layout="@layout/fragment_myfragment" />
像这样写
<fragment
android:id="@+id/fragment_myfragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.myapp.jimbob.android.ui.fragments.MyFragment" />
您不能直接在 xml 中为 Fragment
引用类名,因为它不扩展 View
关于android - 类不是 View android.support.v4.app.Fragment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20902408/
我有一个像这样的 fragment 栈 F1 -> F2 -> F3 -> F4 -> F5 现在我需要删除 F2、F3、F4 fragment 。 我需要如果我从 F5 fragment 按下后退按
我需要帮助来理解以下场景的工作原理以及如何实现结果。 我有一个名为 ShoppingCart 的类。它有一个名为 addItemsToShoppingCartFromPreviousOrder 的方法
我有一个包含 ViewPager 的 fragment 。这个 ViewPager 显然是由其他 Fragments 填充的。 我的问题是,ViewPager 中的 Fragment 是否有任何方法(
所以我正在实现一个 FragmentActivity 并尝试添加一个 fragment ,但是我遇到了多个问题。我以前做过这个,实际上我使用的代码与上一个项目(它工作的地方)相同,但由于某种原因它在这
Closed. This question needs details or clarity。它当前不接受答案。
我想将 Android X fragment (androidx.fragment.app.Fragment) 转换为 Android native fragment (android.app.Fra
假设我有一个包含 10 列文本类型 (20) 的 SQLite 表。 ListFragment 将从数据库中提取 4 列并使用 SimpleCursorAdapter 显示在列表中。 选择后,List
我有一个对话框 fragment ,我为延迟初始化创建了一个类。当我显示对话框时,它显示正常。但是,当我关闭对话框时,它崩溃的原因是: fragment 与 fragment 管理器无关。 我也尝试过
我想在 View 分页器更改为 fragment 时刷新该 fragment 。 package com.mcivisoft.rcbeam; import android.os.Bundle; imp
我有一个名为的 Activity MainActivity 我在容器 R.id.mainContainer 中添加了 fragment “BenefitFragment”。 在 BenefitFrag
所以我有这个 ClientListView,效果很好,可以显示客户,我可以单击一个客户并在右侧获取他们的详细信息(在我的第二个 fragment 中)。由此处的布局定义: 这很好用,但后来我
我试过这段代码,但点击第一个 fragment 中的按钮并没有改变第二个 fragment 中的字符串值。 这是第一个 fragment 的 kotlin 文件。它有两个按钮,点击它们可以更改字符串值
我有以下情况:我打开 fragment A 和目标,通过按钮的单击事件转到 fragment B。当我在 fragment B 中并点击后退按钮(为了返回 fragment A) 我想将一些参数传递给
我制作了一个 NavigationDrawer fragment ,其中包含 Home、Settings、Feedback 等项目。 home 项在点击 home 时应该打开,home 是在应用程序启
我正在一个接一个地替换 2 个 fragment ,两个 fragment 都有不同的选项菜单。当我替换第二个 fragment 时,它也显示第一个 fragment 的菜单。 setHasOptio
我有问题: android.app.Fragment$InstantiationException: Unable to instantiate fragment ${packageName}.${a
我正在研究 fragment 转换。当我用第二个 fragment 替换第一个 fragment 时,它出现在第一个 fragment 的下方。我希望它移动到第一个 fragment 之上。我该怎么做
我在抽屉导航里总共有 12 个 fragment 。每个 fragment 都有 volley 方法。每个 fragment 都显示自己的 Volley 响应,除了 position = 1 和 po
我在我的 Activity 中使用了两个 fragment 。最初我将向 Activity 添加一个 fragment 。然后在第一个 fragment 中使用监听器我想用第二个 fragment 替
我正在实现一个“fragments-101”程序,当相应的按钮被点击时我会替换一个 fragment 。然而,下面的事情发生了: 为什么会这样?为什么初始 fragment 没有被完全替换?MainA
我是一名优秀的程序员,十分优秀!