android 无法转换为android.support.v4.app.Fragment

package com.example.myapplication;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button button = (Button) findViewById(R.id.button);
    button.setOnClickListener(this);
    replaceFragment(new RightFragment());
}

@Override
public void onClick(View view) {
    switch (view.getId()){
        case R.id.button:
            replaceFragment(new AnotherRightFragment());
            break;
        default:
            break;
    }
}
private void replaceFragment(Fragment fragment){
    FragmentManager fragmentMananger = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentMananger.beginTransaction();
    transaction.replace(R.id.right_fragment,fragment);
    transaction.addToBackStack(null);
    transaction.commit();
}

}

当导入V4包时图片说明

当导入app.Fragment包时图片说明

两者不能兼容啊,这程序好像没法执行

2个回答

qq_32793555
帕斯伦川三 谢谢啦,我知道了,全部都改成V4包就可以
2 年多之前 回复

继承FragmentActivity

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
android.support.v4.app.FragmentActivity报错

java.lang.NoSuchMethodError: android.support.v4.app.FragmentActivity.getFragmentManager 实用的第三方框架 andbase 在安卓2.3.6的三星手机上报这个错误,停止运行 其他手机正常,三星总是板锉,该怎么解答 在线等 ![图片说明](https://img-ask.csdn.net/upload/201703/11/1489196373_165997.png)

cannot cast 'android.support.v4.app.FragmentTransaction' to 'android.app.FragmentTransaction

网上的解决方法针对的都是把FragmentTransaction转化成V4包下的FragmentTransaction有问题 但是,我却遇到了相反的情况。 无法由V4包下的FragmentTransaction转化成app.FragmentTransaction 有没有高人来指点一下啊?? 注:**extends android.support.v4.app.Fragment**这个千万不能改 ``` package com.example.myslidepage.Fragment; import android.app.FragmentManager; import android.app.FragmentTransaction; import android.content.Context; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.*; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import com.example.myslidepage.R; /** * Created by lenovo on 4/30/2019. */ public class Fragment2 extends android.support.v4.app.Fragment implements View.OnClickListener { public Button btn_news,btn_contact,btn_message,btn_setting; public MyFragment f1,f2,f3,f4; @Nullable public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { View view =inflater.inflate(R.layout.tab2,container,false); btn_news = view.findViewById(R.id.btn_news); btn_contact = view.findViewById(R.id.btn_contact); btn_message = view.findViewById(R.id.btn_message); btn_setting = view.findViewById(R.id.btn_setting); btn_news.setOnClickListener(this); btn_contact.setOnClickListener(this); btn_message.setOnClickListener(this); btn_setting.setOnClickListener(this); //第一次初始化首页默认显示第一个fragment initFragment1(); initFragment2(); initFragment3(); initFragment4(); return view; } @Override public void onClick(View v) { if(v==btn_news){ initFragment1(); } else if(v==btn_message){ initFragment2(); } else if(v==btn_contact){ initFragment3(); } else{ initFragment4(); } } private void initFragment1(){ android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); //开启事务,fragment的控制是由事务来实现的 FragmentTransaction transaction=(FragmentTransaction)fragmentManager.beginTransaction(); //第一种方式(add),初始化fragment并添加到事务中,如果为null就new一个 if(f1 == null){ f1 = new MyFragment("消息",R.drawable.message_selected); transaction.add(R.id.main_frame_layout, f1); } //隐藏所有fragment hideFragment(transaction); //显示需要显示的fragment transaction.show(f1); transaction.commit(); } private void initFragment2(){ android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction transaction=(FragmentTransaction)fragmentManager.beginTransaction(); if(f2 == null){ f2 = new MyFragment("消息",R.drawable.message_selected); transaction.add(R.id.main_frame_layout, f2); } //隐藏所有fragment hideFragment(transaction); //显示需要显示的fragment transaction.show(f2); transaction.commit(); } private void initFragment3(){ android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction transaction=(FragmentTransaction)fragmentManager.beginTransaction(); if(f3 == null){ f3 = new MyFragment("消息",R.drawable.message_selected); transaction.add(R.id.main_frame_layout, f3); } //隐藏所有fragment hideFragment(transaction); //显示需要显示的fragment transaction.show(f3); transaction.commit(); } private void initFragment4(){ android.support.v4.app.FragmentManager fragmentManager = getActivity().getSupportFragmentManager(); FragmentTransaction transaction=(FragmentTransaction)fragmentManager.beginTransaction(); if(f4 == null){ f4 = new MyFragment("消息",R.drawable.message_selected); transaction.add(R.id.main_frame_layout, f4); } //隐藏所有fragment hideFragment(transaction); //显示需要显示的fragment transaction.show(f4); transaction.commit(); } //这个方法其实很巧,这个hide方法看一眼就是唬人的。这个方法将所有的fragment都hide了,因为他的判断条件是if(f1 != null) //因为一开始初始化的时候,f1f2f3都已经初始化一遍了,所以不可能都为空,既然都不为空,那就都隐藏。然后点击哪个方法,那个再显示。 private void hideFragment(FragmentTransaction transaction) { if(f1 != null){ transaction.hide(f1); } if(f2 != null){ transaction.hide(f2); } if(f3 != null){ transaction.hide(f3); } if(f4 != null){ transaction.hide(f4); } } } ```

Android studio报错:无法解析v4.app.FragmentActivity

import android.content.Context; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; import com.bigkoo.convenientbanner.ConvenientBanner; import com.bigkoo.convenientbanner.holder.CBViewHolderCreator; import com.bigkoo.convenientbanner.holder.Holder; import com.example.administrator.cookbook.R; import com.example.administrator.cookbook.books.CookBookPresenter; import com.example.administrator.cookbook.books.CookBookPresenterImpl; import com.example.administrator.cookbook.books.CookBookView; import com.example.administrator.cookbook.cookbook.beans.CookBook; import com.squareup.picasso.Picasso; import java.util.ArrayList; import java.util.List; public class HomeFragment extends Fragment implements CookBookView{ ConvenientBanner convenientBanner; ListView listView; static List<Integer> localImages = new ArrayList<>(); CookBookPresenter cookBookPresenter; List<CookBook> list; static { localImages.add(R.drawable.test01); localImages.add(R.drawable.test02); localImages.add(R.drawable.test03); localImages.add(R.drawable.test04); } @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); list = new ArrayList<>(); cookBookPresenter = new CookBookPresenterImpl(this); cookBookPresenter.getCookBookListById(getActivity(),"xxx"); } @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_home,container,false); initViews(view); initBanner(); return view; } void initViews(View view){ listView = (ListView) view.findViewById(R.id.listview); convenientBanner = (ConvenientBanner)view.findViewById(R.id.convenientBanner); } @Override public void setCookBookList(List<CookBook> list) { this.list = list; } @Override public void setFail() { } class MyAdapter extends BaseAdapter{ @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { View myView; if(convertView == null){ myView = getActivity().getLayoutInflater().inflate(R.layout.list_cookbook_item,null); }else { myView = convertView; } ImageView iv = (ImageView) myView.findViewById(R.id.imageView); TextView tv1 = (TextView) myView.findViewById(R.id.title); TextView tv2 = (TextView) myView.findViewById(R.id.intro); CookBook cookBook = list.get(position); String url = cookBook.getAlbums().get(0); String title = cookBook.getTitle(); String intro = cookBook.getImtro(); tv1.setText(title); tv2.setText(intro); Picasso.with(getActivity()).load(url).resize(120,120).into(iv); return myView; } } void initBanner(){ convenientBanner.setPages( new CBViewHolderCreator<LocalImageHolderView>() { @Override public LocalImageHolderView createHolder() { return new LocalImageHolderView(); } }, localImages) //设置两个点图片作为翻页指示器,不设置则没有指示器,可以根据自己需求自行配合自己的指示器,不需要圆点指示器可用不设 .setPageIndicator(new int[]{R.drawable.ic_page_indicator, R.drawable.ic_page_indicator_focused}) //设置指示器的方向 .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT); } class LocalImageHolderView implements Holder<Integer> { private ImageView imageView; @Override public View createView(Context context) { imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.FIT_XY); return imageView; } @Override public void UpdateUI(Context context, final int position, Integer data) { imageView.setImageResource(data); } } } 其中Picasso.with(getActivity()).load(url).resize(120,120).into(iv);中with报错Cannot resolve method 'with(android.support.v4.app.FragmentActivity),该如何解决,本人小白能否给出详细过程

Viewpager中的fragment内嵌fragment,滑动报错

02-07 16:26:30.621: E/AndroidRuntime(19951): java.lang.NullPointerException 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.Fragment.instantiate(Fragment.java:399) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentState.instantiate(Fragment.java:97) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1790) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.Fragment.performCreate(Fragment.java:1489) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:893) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.view.ViewPager.populate(ViewPager.java:1128) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.view.ViewPager.populate(ViewPager.java:975) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1505) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.View.measure(View.java:15575) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.View.measure(View.java:15575) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.View.measure(View.java:15575) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.LinearLayout.measureVertical(LinearLayout.java:681) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.View.measure(View.java:15575) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5107) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 02-07 16:26:30.621: E/AndroidRuntime(19951): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2423) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.View.measure(View.java:15575) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2033) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1251) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1427) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1144) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4730) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.Choreographer.doCallbacks(Choreographer.java:555) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.Choreographer.doFrame(Choreographer.java:525) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.os.Handler.handleCallback(Handler.java:615) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.os.Handler.dispatchMessage(Handler.java:92) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.os.Looper.loop(Looper.java:137) 02-07 16:26:30.621: E/AndroidRuntime(19951): at android.app.ActivityThread.main(ActivityThread.java:4947) 02-07 16:26:30.621: E/AndroidRuntime(19951): at java.lang.reflect.Method.invokeNative(Native Method) 02-07 16:26:30.621: E/AndroidRuntime(19951): at java.lang.reflect.Method.invoke(Method.java:511) 02-07 16:26:30.621: E/AndroidRuntime(19951): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 02-07 16:26:30.621: E/AndroidRuntime(19951): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 02-07 16:26:30.621: E/AndroidRuntime(19951): at dalvik.system.NativeStart.main(Native Method)

《求助》android studio fragmentTabHost使用问题

为什么在android studio 上用android.support.v4.app.FragmentTabHost会出现Exception raised during rendering: No tab known for tag null这样的 问题???

fragment 中 mRecyclerView.setLayoutManager()报错???????

Fragment中 onCreateView代码: ``` public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_fragment2, container, false); initDatas(); mRecyclerView = view.findViewById(R.id.item2); mRVAdapter = new RVAdapter(getActivity(),mData); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false));//错误行; mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.setAdapter(mRVAdapter); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),DividerItemDecoration.VERTICAL)); return view; } ``` adapter代码: ``` public class RVAdapter extends RecyclerView.Adapter<MyViewHolder> { private Context context; private List<String> data; public RVAdapter(Context context , List<String> data){ this.context = context; this.data = data; } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { //创建ViewHolder View view = LayoutInflater.from (viewGroup.getContext ()).inflate (R.layout.item2,viewGroup,false); MyViewHolder viewHolder = new MyViewHolder(view); return viewHolder; } @Override public void onBindViewHolder(@NonNull MyViewHolder holder, int pos) { // 绑定viewholder holder.tv.setText(data.get(pos)); } @Override public int getItemCount() { return data.size(); } } class MyViewHolder extends RecyclerView.ViewHolder{ TextView tv; public MyViewHolder(@NonNull View arg0) { super(arg0); tv = arg0.findViewById(R.id.item2); } } ``` 所报错误: ``` 2019-04-18 21:18:25.483 25820-25820/cn.daun.player E/AndroidRuntime: FATAL EXCEPTION: main Process: cn.daun.player, PID: 25820 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference at cn.daun.player.view.Fragment2.onCreateView(Fragment2.java:37) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146) at android.support.v4.view.ViewPager.populate(ViewPager.java:1244) at android.support.v4.view.ViewPager.populate(ViewPager.java:1092) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1622) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1535) at android.widget.LinearLayout.measureVertical(LinearLayout.java:825) ```

cannot cast "androidx fragment" to "support fragment"

![图片说明](https://img-ask.csdn.net/upload/202003/20/1584668879_660864.jpg)![图片说明](https://img-ask.csdn.net/upload/202003/20/1584668888_748114.jpg)![图片说明](https://img-ask.csdn.net/upload/202003/20/1584668919_637912.jpg) 请问要怎么改或者导入呢

Android Studio找不到FragmentActivity类

FragmentActivity类是在android.support.v4中的,但是我没办法import到程序中,根据网上的说明要导入jar包,但是我发现在Android Studio\sdk\extras\android\support\v4中已经存在了,为什么还是无法使用,这个类到底如何使用

android FragmentManager 的两种不同版本

1、 android.app.FragmentManager 2、 android.support.v4.app.FragmentManager fragmentManager= getSupportFragmentManager(); for(Fragment fragment:mFragment){ android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.remove(fragment); fragmentTransaction.commit(); }

在viewpager和fragment中嵌套listview,出现setAdapter空指针情况。

在viewpager和fragment中嵌套listview,出现setAdapter空指针情况。 为了实现滑动切换界面,我写了三个fragment,在一个fragment中加入了一个listview,怎么启动都是空指针。 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference at com.example.tabhost_02.Fragment_Device.onActivityCreated(Fragment_Device.java:33) at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2619) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904) at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:1696) at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:299) at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:235) at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244) at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092) at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22002) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at androidx.appcompat.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:403) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22002) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721) at android.view.View.measure(View.java:22002) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1498) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:723) at android.view.Choreographer.doFrame(Choreographer.java:658) <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/textView5" android:layout_width="358dp" android:layout_height="wrap_content" android:text="状态详情" android:textColor="#000000" android:textSize="20sp" android:textStyle="bold" /> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="176dp" android:text="TextView" /> <TextView android:id="@+id/textView3" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="部件信息" android:textColor="#000000" android:textSize="20sp" android:textStyle="bold" /> <TextView android:id="@+id/textView6" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="温度传感器" android:textColor="#2196F3" android:textSize="18sp" android:textStyle="bold" /> <ListView android:id="@+id/lv" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout> public class Fragment_Device extends Fragment { private List<Info> infos = new ArrayList<>(); private ListView device_info=null; public Fragment_Device(){ } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.activity_device, container, false); initInfo(); return view; } public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); initInfo(); } private void initInfo() { Info dev_1 = new Info("室内环境监控", "20摄氏度", "100小时", "2019-05-01 09:00:00"); infos.add(dev_1); Info dev_2 = new Info("室内环境监控", "25摄氏度", "100小时", "2019-05-01 09:08:00"); infos.add(dev_2); Info dev_3 = new Info("室内环境监控", "23摄氏度", "100小时", "2019-05-01 10:00:00"); infos.add(dev_3); Info dev_4 = new Info("室内环境监控", "28摄氏度", "100小时", "2019-05-01 10:30:00"); infos.add(dev_4); InfoAdapter infoAdapter = new InfoAdapter(infos,getContext()); View view = LayoutInflater.from(getContext()).inflate(R.layout.list_item,null); infos=view.findViewById(R.id.lv); device_info = view.findViewById(R.id.lv); device_info.setAdapter(infoAdapter); } }

android 底部4个tabar来回快速切换 奔溃 No host错误

AndroidRuntime: FATAL EXCEPTION: main Process: com.yizooo.yizooo, PID: 21870 java.lang.IllegalStateException: No host at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1235) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1230) at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2042) at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1976) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1092) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) at android.os.Handler.handleCallback(Handler.java:743) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5546) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684) 10-21 18:25:32.393 27110-27110/com.yizooo.yizooo E/SMACK-Voe: enter JNI_OnLoad 截图: ![图片说明](https://img-ask.csdn.net/upload/201610/21/1477045669_89543.png)

IllegalArgumentException

Process: com.example.qianfan, PID: 32599 java.lang.IllegalArgumentException: No view found for id 0x7f0d00b4 (com.example.qianfan:id/vp) for fragment Fragment_A{76a164f #1 id=0x7f0d00b4 android:switcher:2131558580:0} at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1293) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1984) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143) at android.support.v4.view.ViewPager.populate(ViewPager.java:1268) at android.support.v4.view.ViewPager.populate(ViewPager.java:1116) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642) at android.view.View.measure(View.java:18811) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18811) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:18811) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:18811) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2127) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1243) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1479) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860) at android.view.Choreographer.doCallbacks(Choreographer.java:672) at android.view.Choreographer.doFrame(Choreographer.java:608) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846) at android.os.Handler.handleCallback(Handler.java:742) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:5524) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)

app安装后点击闪退,log如下,请问是什么问题啊,麻烦各位指教一下

08-29 21:37:56.458 4962-4962/? I/art: Late-enabling -Xcheck:jni 08-29 21:37:56.618 4962-4962/com.example.coolweather W/System: ClassLoader referenced unknown path: /data/app/com.example.coolweather-1/lib/arm64 08-29 21:37:56.674 4962-4962/com.example.coolweather W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 08-29 21:37:56.745 4962-4962/com.example.coolweather D/AndroidRuntime: Shutting down VM 08-29 21:37:56.745 4962-4962/com.example.coolweather E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.coolweather, PID: 4962 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.coolweather/com.example.coolweather.MainActivity}: java.lang.NumberFormatException: null at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2695) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2768) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1481) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6153) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758) Caused by: java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:483) at java.lang.Integer.parseInt(Integer.java:556) at org.litepal.parser.LitePalParser.usePullParse(LitePalParser.java:160) at org.litepal.parser.LitePalParser.parseLitePalConfiguration(LitePalParser.java:102) at org.litepal.parser.LitePalAttr.loadLitePalXMLConfiguration(LitePalAttr.java:99) at org.litepal.parser.LitePalAttr.getInstance(LitePalAttr.java:90) at org.litepal.tablemanager.Connector.buildConnection(Connector.java:104) at org.litepal.tablemanager.Connector.getWritableDatabase(Connector.java:63) at org.litepal.tablemanager.Connector.getDatabase(Connector.java:87) at org.litepal.crud.DataSupport.findAll(DataSupport.java:1027) at org.litepal.crud.DataSupport.findAll(DataSupport.java:994) at com.example.coolweather.ChooseAreaFragment.queryProvinces(ChooseAreaFragment.java:115) at com.example.coolweather.ChooseAreaFragment.onActivityCreated(ChooseAreaFragment.java:106) at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2201) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1326) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2900) at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201) at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:603) at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1249) at android.app.Activity.performStart(Activity.java:6722) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2768)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1481)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6153)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)  08-29 21:37:56.752 4962-4962/? I/Process: Sending signal. PID: 4962 SIG: 9

DialogFragment中使用viewpager+fragment时出现问题

fragment does not have a view ``` package com.yidi.livelibrary.widget.dialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; 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.view.ViewPager; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.TextView; import com.hn.library.utils.AppLogger; import com.yidi.livelibrary.R; import com.yidi.livelibrary.ui.fragment.HnContributionFragment; import java.util.ArrayList; import java.util.List; /** * Menu Dialog */ public class HnContributionDialog extends DialogFragment implements View.OnClickListener { private FragmentActivity mActivity; private TextView tvLeft; private TextView tvMiddle; private TextView tvRight; private ViewPager viewPager; private String anchor_user_id; private ArrayList<Fragment> mFragments = new ArrayList<>(); public static HnContributionDialog newInstance(String anchor_user_id) { Bundle bundle = new Bundle(); bundle.putString("anchor_user_id",anchor_user_id); HnContributionDialog sDialog = new HnContributionDialog(); sDialog.setArguments(bundle); return sDialog; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mActivity = getActivity(); Bundle bundle = getArguments(); if (bundle != null) { anchor_user_id = bundle.getString("anchor_user_id"); AppLogger.e(anchor_user_id); } } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { View view = View.inflate(mActivity, R.layout.live_left_dialog, null); Dialog dialog = null; dialog = new Dialog(mActivity, R.style.LeftDialog); dialog.setContentView(view); dialog.setCanceledOnTouchOutside(true); Window alertWindow = dialog.getWindow(); WindowManager.LayoutParams params = alertWindow.getAttributes(); alertWindow.setGravity(Gravity.LEFT); params.height = (mActivity.getWindowManager().getDefaultDisplay().getHeight()); params.width = mActivity.getWindowManager().getDefaultDisplay().getWidth(); alertWindow.setAttributes(params); dialog.getWindow().setDimAmount(0f); //初始化组件 initView(view); return dialog; } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); } /** * 初始化视图 * * @param view */ private void initView(View view) { tvLeft = (TextView) view.findViewById(R.id.tvLeft); tvMiddle = (TextView) view.findViewById(R.id.tvMiddle); tvRight = (TextView) view.findViewById(R.id.tvRight); viewPager = (ViewPager) view.findViewById(R.id.vp); view.findViewById(R.id.vOut).setOnClickListener(this); tvLeft.setSelected(true); tvLeft.setOnClickListener(this); tvMiddle.setOnClickListener(this); tvRight.setOnClickListener(this); viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { switch (position) { case 0: tvLeft.setSelected(true); tvMiddle.setSelected(false); tvRight.setSelected(false); break; case 1: tvLeft.setSelected(false); tvMiddle.setSelected(true); tvRight.setSelected(false); break; case 2: tvLeft.setSelected(false); tvMiddle.setSelected(false); tvRight.setSelected(true); break; default: break; } } @Override public void onPageScrollStateChanged(int state) { } }); mFragments.add(HnContributionFragment.newInstance("day",anchor_user_id)); mFragments.add(HnContributionFragment.newInstance("week",anchor_user_id)); mFragments.add(HnContributionFragment.newInstance("all",anchor_user_id)); PagerAdapter adapter = new PagerAdapter(getFragmentManager(), mFragments); viewPager.setAdapter(adapter); } public void setViewPager(){ } class PagerAdapter extends FragmentPagerAdapter { private List<Fragment> mFragments; public PagerAdapter(FragmentManager fm, List<Fragment> mFragments) { super(fm); this.mFragments = mFragments; } @Override public int getCount() { return mFragments.size(); } @Override public CharSequence getPageTitle(int position) { return null; } @Override public Fragment getItem(int position) { Fragment fragment = mFragments.get(position); return fragment; } } @Override public void onClick(View v) { int id = v.getId(); if (id == R.id.tvLeft) { tvLeft.setSelected(true); tvMiddle.setSelected(false); tvRight.setSelected(false); } else if (id == R.id.tvMiddle) { tvLeft.setSelected(false); tvMiddle.setSelected(true); tvRight.setSelected(false); } else if (id == R.id.tvRight) { tvLeft.setSelected(false); tvMiddle.setSelected(false); tvRight.setSelected(true); } else if (id == R.id.vOut) { dismiss(); } } @Override public void onDestroy() { super.onDestroy(); } @Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); mActivity = null; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO: inflate a fragment view View rootView = super.onCreateView(inflater, container, savedInstanceState); return rootView; } @Override public void onDestroyView() { super.onDestroyView(); } } ```

android 错误: 不兼容的类型: ImageFragment无法转换为Fragment

package com.example.actionbar; import android.app.ActionBar; import android.app.Activity; import android.app.FragmentTransaction; import android.os.Bundle; import android.support.v4.app.Fragment; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar =getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); TextFragment aFragment =new TextFragment(); ActionBar.Tab tab1=actionBar.newTab(); tab1.setText("文字"); tab1.setIcon(R.drawable.ic_launcher_foreground); tab1.setTabListener(new ListenerA(aFragment)); actionBar.addTab(tab1); ImageFragment bFragment = new ImageFragment(); ActionBar.Tab tab2 = actionBar.newTab(); tab2.setText("图片"); tab2.setTabListener(new Listenerb(bFragment)); actionBar.addTab(tab2); } private class ListenerA implements ActionBar.TabListener { private TextFragment mFragemnt; public ListenerA(TextFragment fragment) { mFragemnt =fragment; } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { ft.add(R.id.fragment_content, mFragemnt, null); } //mFragemnt 这出错 下面的也爆红 @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { ft.remove(mFragemnt); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } } private class Listenerb implements ActionBar.TabListener { private ImageFragment ImFragment; public Listenerb(ImageFragment fragment) { ImFragment =fragment ; } public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { ft.add(R.id.fragment_content, ImFragment, null); } //ImFragment 这出错 下面的也爆红 public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { ft.remove(ImFragment); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } } }

Error inflating class fragment

android.view.InflateException: Binary XML file line #8: Error inflating class fragment at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:808) at android.view.LayoutInflater.rInflate(LayoutInflater.java:851) at android.view.LayoutInflater.inflate(LayoutInflater.java:510) at android.view.LayoutInflater.inflate(LayoutInflater.java:420) at com.example.administrator.baba.Fragments.HomeFragment.getView(HomeFragment.java:96) at android.support.v4.app.BackStackRecord.setFirstOut(BackStackRecord.java:813) at android.support.v4.app.BackStackRecord.calculateFragments(BackStackRecord.java:885) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:719) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1677) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:536) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5743) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1077) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843) Caused by: java.lang.IllegalArgumentException: Binary XML file line #8: Duplicate id 0x7f0b0078, tag null, or parent id 0xffffffff with another fragment for com.example.administrator.baba.CycleViews.CycleViewPager at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2146) at android.app.Activity.onCreateView(Activity.java:5460) at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:36) at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:75) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:778) at android.view.LayoutInflater.rInflate(LayoutInflater.java:851)  at android.view.LayoutInflater.inflate(LayoutInflater.java:510)  at android.view.LayoutInflater.inflate(LayoutInflater.java:420)  at com.example.administrator.baba.Fragments.HomeFragment.getView(HomeFragment.java:96)  at android.support.v4.app.BackStackRecord.setFirstOut(BackStackRecord.java:813)  at android.support.v4.app.BackStackRecord.calculateFragments(BackStackRecord.java:885)

报错view.InflateException: Binary XML file line

比较老的项目,主界页面使用的TabActivity切换,在首页的viewpager中的fragment的布局文件中报错,布局文件报错为一个TextView,样式很简单,但是报错,尝试将该TextView注释后,依然报错,显示为首页的另一个控件,感觉和项目配置有关,目前仍然找不到错误,在华为Mate10上打开直接关闭,在荣耀v8和mate9pro上可以正常打开,以下是报错日志,求大神指点 android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class android.widget.TextView Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class android.widget.TextView Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at android.view.LayoutInflater.createView(LayoutInflater.java:647) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at com.tidemedia.nntv.sliding.fragment.TuijianFragment.onCreateView(TuijianFragment.java:134) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1984) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143) at android.support.v4.view.ViewPager.populate(ViewPager.java:1268) at android.support.v4.view.ViewPager.populate(ViewPager.java:1116) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642) at android.view.View.measure(View.java:21998) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721) at android.view.View.measure(View.java:21998) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580) 以下是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"> <RelativeLayout android:layout_width="match_parent" android:layout_height="180dp"> <android.support.v4.view.ViewPager android:id="@+id/newsGallery" android:layout_width="match_parent" android:layout_height="180dp" /> <RelativeLayout android:layout_width="match_parent" android:layout_height="30dp" android:layout_alignParentBottom="true" android:background="#64000000"> <android.widget.TextView android:id="@+id/viewpager_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:lines="1" android:textColor="@color/white" android:textSize="15sp" /> </RelativeLayout>

PopupWindow中放入Viewpager+Fragment 哪位 大神来指点一下

Process: com.example.qianfan, PID: 32599 java.lang.IllegalArgumentException: No view found for id 0x7f0d00b4 (com.example.qianfan:id/vp) for fragment Fragment_A{76a164f #1 id=0x7f0d00b4 android:switcher:2131558580:0} at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1293) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149) at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1984) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:626) at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143) at android.support.v4.view.ViewPager.populate(ViewPager.java:1268) at android.support.v4.view.ViewPager.populate(ViewPager.java:1116) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1642) at android.view.View.measure(View.java:18811) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465) at android.widget.LinearLayout.measureVertical(LinearLayout.java:748) at android.widget.LinearLayout.onMeasure(LinearLayout.java:630) at android.view.View.measure(View.java:18811) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:18811) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5952) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure(View.java:18811) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2127) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1243) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1479) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860) at android.view.Choreographer.doCallbacks(Choreographer.java:672) at android.view.Choreographer.doFrame(Choreographer.java:608) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846) at android.os.Handler.handleCallback(Handler.java:742) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:5524) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:630)

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

差点跪了...

最近微信又搞出了一个大利器,甚至都上了热搜,当然消息最敏捷的自媒体人,纷纷都开通了自己的视频号。01 视频号是什么呢?视频号是微信体系内的短视频,它不同...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

Vue回炉重造之router路由(更新中)

你好,我是Vam的金豆之路,可以叫我豆哥。2019年年度博客之星、技术领域博客专家。主要领域:前端开发。我的微信是 maomin9761,有什么疑问可以加我哦,自己创建了一个微信技术交流群,可以加我邀请你一起交流学习。最后自己也创建了一个微信公众号,里面的文章是我自己精挑细选的文章,主要介绍各种IT新技术。欢迎关注哦,微信搜索:臻美IT,等你来。 欢迎阅读本博文,本博文主要讲述【】,文字通...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大胆预测下未来5年的Web开发

在2019年的ReactiveConf 上,《Elm in Action》的作者Richard Feldman对未来5年Web开发的发展做了预测,很有意思,分享给大家。如果你有机会从头...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

立即提问
相关内容推荐