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);
        }
    }


}

1个回答

import android.app.FragmentManager; 把这个导包删除
import android.app.FragmentTransaction; 把这个换成v4包

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

程序抛出错误: 不兼容的类型: android.app.Fragment无法转换为android.support.v4.app.Fragment Error:(34, 47) 错误: 不兼容的类型: android.app.Fragment无法转换为android.support.v4.app.Fragment Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. ``` package fragment.example.com.fragmenttest; import android.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; 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 v){ switch (v.getId()){ case R.id.button: replaceFragment(new AnotherRightFragment()); break; default:break; } } private void replaceFragment(Fragment fragment) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.right_layout,fragment); transaction.commit(); } } ``` 报错位置是 transaction.replace(R.id.right_layout,fragment);的fragment

app.ActionBar无法转换为support.v7.app.ActionBar

![图片说明](https://img-ask.csdn.net/upload/201804/09/1523273163_648383.png) ![图片说明](https://img-ask.csdn.net/upload/201804/09/1523273181_381415.png) 即使import android.app.ActionBar;不用android.support.v7.app.ActionBar也会提示我没有覆盖,但实际上重写了。

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 viewPager出现的强转异常

用一个页面切换到另外一个页面出现了异常 02-19 19:56:32.645: E/GED(11205): Failed to get GED Log Buf, err(0) 02-19 19:56:37.141: E/AndroidRuntime(11205): FATAL EXCEPTION: main 02-19 19:56:37.141: E/AndroidRuntime(11205): Process: com.example.shuyannvshen, PID: 11205 02-19 19:56:37.141: E/AndroidRuntime(11205): java.lang.ClassCastException: com.viewpagerindicator.CirclePageIndicator$SavedState cannot be cast to android.widget.HorizontalScrollView$SavedState 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.widget.HorizontalScrollView.onRestoreInstanceState(HorizontalScrollView.java:1667) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.View.dispatchRestoreInstanceState(View.java:14030) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3018) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3024) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.view.View.restoreHierarchyState(View.java:14008) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.Fragment.restoreViewState(Fragment.java:449) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:964) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1484) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:450) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.os.Handler.handleCallback(Handler.java:815) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.os.Handler.dispatchMessage(Handler.java:104) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.os.Looper.loop(Looper.java:194) 02-19 19:56:37.141: E/AndroidRuntime(11205): at android.app.ActivityThread.main(ActivityThread.java:5691) 02-19 19:56:37.141: E/AndroidRuntime(11205): at java.lang.reflect.Method.invoke(Native Method) 02-19 19:56:37.141: E/AndroidRuntime(11205): at java.lang.reflect.Method.invoke(Method.java:372) 02-19 19:56:37.141: E/AndroidRuntime(11205): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) 02-19 19:56:37.141: E/AndroidRuntime(11205): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

关于java.lang.ClassCastException的问题 求大神解答 错误日志贴上 谢谢了

FATAL EXCEPTION: main Process: com.example.fxr.myapplication, PID: 10943 java.lang.ClassCastException: com.example.fxr.myapplication.friends_top cannot be cast to android.support.v4.app.Fragment at com.example.fxr.myapplication.messagetop$1.getItem(messagetop.java:54) at android.support.v4.app.FragmentPagerAdapter.instantiateItem(FragmentPagerAdapter.java:101) at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1006) at android.support.v4.view.ViewPager.populate(ViewPager.java:1154) at android.support.v4.view.ViewPager.populate(ViewPager.java:1088) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614) at android.view.View.measure(View.java:16514) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052) at android.widget.LinearLayout.onMeasure(LinearLayout.java:590) at android.view.View.measure(View.java:16514) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052) at android.widget.LinearLayout.onMeasure(LinearLayout.java:590) at android.view.View.measure(View.java:16514) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:847) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16514) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at android.view.View.measure(View.java:16514) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:16514) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291) at android.view.View.measure(View.java:16514) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:544) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5095) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) at dalvik.system.NativeStart.main(Native Method)

java.lang.Integer cannot be cast to

public List<Materials> findAllMaterialsByAppid(Integer appid) { String hql1 = "select medid from Materials where appid = ? and pid = 0"; List<Materials> list = this.hibernateTemplate.find(hql1, appid); if (list != null && list.size() > 0) { if(list.get(0).getMedid() != null){ Integer medid = (Integer)list.get(0).getMedid(); String hql2 = "from Materials where appid = ? and pid = ?"; return this.hibernateTemplate.find(hql2, appid, medid); } 请教一下大家

菜鸟请大神指教,关于在fragment中加入vierpager的问题

package com.yanis.yc_ui_fragment_menu; import java.util.ArrayList; import java.util.List; import com.health.Circle; import com.health.Information; import com.health.Market; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class FragmentCategory extends Fragment{ //声明viewpager private ViewPager viewPager; //声明数据源 private List<Fragment> list; //声明适配器 private FragmentStatePagerAdapter adapter; //声明view private View view; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view=inflater.inflate(R.layout.fragment_category, container, false); init(); return view; } //初始化控件的方法 private void init() { // TODO Auto-generated method stub //得到viewpager viewPager=(ViewPager) view.findViewById(R.id.viewpager_tab); //得到列表 list=new ArrayList<Fragment>(); //往列表里添加fragment Information information=new Information(); Market market=new Market(); Circle circle=new Circle(); list.add(information); list.add(market); list.add(circle); //声明适配器 adapter=new FragmentStatePagerAdapter(getChildFragmentManager()) { @Override public int getCount() { // TODO Auto-generated method stub return list.size(); } @Override public Fragment getItem(int arg0) { // TODO Auto-generated method stub return list.get(arg0); } @Override public Object instantiateItem(ViewGroup arg0, int arg1) { // TODO Auto-generated method stub return super.instantiateItem(arg0, arg1); } @Override public void destroyItem(ViewGroup container, int position, Object object) { // TODO Auto-generated method stub super.destroyItem(container, position, object); } }; viewPager.setAdapter(adapter); } }

新人使用DrawerLayout遇到一点小问题,求助大神

![图片说明](https://img-ask.csdn.net/upload/201806/09/1528524473_106402.jpg) 没有显示Toolbar 代码如下: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> </android.support.v7.widget.Toolbar> </FrameLayout> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="start" android:text="This is menu" android:textSize="30sp" android:background="#FFF"/> </android.support.v4.widget.DrawerLayout>

实现FragmentTabhost+ViewPager+Fragment时出现类转换异常

百思不得其解为什么会出现这种类转换错误。也试过不少方法,实在不得其所。 请大触们不吝赐教,谢谢~ 运行报错: > E/AndroidRuntime: FATAL EXCEPTION: main Process: com.wolfgy.news.newsclient, PID: 1109 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wolfgy.news.newsclient/com.wolfgy.news.newsclient.MainActivity}: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.support.v4.view.ViewPager at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2219) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5045) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassCastException: android.widget.FrameLayout cannot be cast to android.support.v4.view.ViewPager at com.wolfgy.news.newsclient.MainActivity.initView(MainActivity.java:84) at com.wolfgy.news.newsclient.MainActivity.onCreate(MainActivity.java:52) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2163) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)  at android.app.ActivityThread.access$800(ActivityThread.java:135)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:136)  at android.app.ActivityThread.main(ActivityThread.java:5045)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)  at dalvik.system.NativeStart.main(Native Method)  备注:这里说的MainActivity.java:84指的是viewPager = (ViewPager)findViewById(R.id.main_viewPager); 这一行。 MainActivity代码如下 ``` public class MainActivity extends FragmentActivity { FragmentTabHost fragmentTabHost; SlidingMenu slidingMenu; List<Fragment> list = new ArrayList<Fragment>(); String[] titles={"新闻中心" ,"博客频道","体育频道","科技频道","财经频道","视频","影音娱乐","读书频道","女性频道","男性频道","军事频道","汽车新闻","教育频道","房地产","游戏频道","星座频道"}; Class[] fragmentArray = {HeadLineFragment.class, BlogFragment.class, SportsFragment.class, ScientistFragment.class,EconomicsFragment.class, VideoFragment.class, EntertainmentFragment.class, ReadingFragment.class, FemaleFragment.class, MaleFragment.class, MilitaryFragment.class,CarsFragment.class, EducationFragment.class, HouseFragment.class, GamesFragment.class,ConstellationFragment.class}; ViewPager viewPager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); initView(); } private void initView(){ fragmentTabHost = (FragmentTabHost)findViewById(R.id.main_fragmentTabHost); fragmentTabHost.setup(this,getSupportFragmentManager(),R.id.main_viewPager); int count = titles.length; for (int i = 0; i < count; i++) { TabHost.TabSpec tabSpec = fragmentTabHost.newTabSpec(titles[i]).setIndicator(getTabItemView(i)); fragmentTabHost.addTab(tabSpec,fragmentArray[i],null); fragmentTabHost.setTag(i); } fragmentTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) { int position = fragmentTabHost.getCurrentTab(); viewPager.setCurrentItem(position); } }); //初始化ViewPager viewPager = (ViewPager)findViewById(R.id.main_viewPager); initPage(); viewPager.setAdapter(new MainActivityFragmentPagerAdapter(getSupportFragmentManager())); viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){ @Override public void onPageSelected(int position) { fragmentTabHost.setCurrentTab(position); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }); } /** * 初始化Fragment */ private void initPage(){ HeadLineFragment headLine = new HeadLineFragment(); BlogFragment blog = new BlogFragment(); SportsFragment sports = new SportsFragment(); ScientistFragment scientistFragment = new ScientistFragment(); EconomicsFragment economicsFragment = new EconomicsFragment(); VideoFragment videoFragment = new VideoFragment(); EntertainmentFragment entertainmentFragment = new EntertainmentFragment(); ReadingFragment readingFragment = new ReadingFragment(); FemaleFragment femaleFragment = new FemaleFragment(); MaleFragment maleFragment = new MaleFragment(); MilitaryFragment militaryFragment = new MilitaryFragment(); CarsFragment carsFragment = new CarsFragment(); EducationFragment educationFragment = new EducationFragment(); HouseFragment houseFragment = new HouseFragment(); GamesFragment gamesFragment = new GamesFragment(); ConstellationFragment constellationFragment = new ConstellationFragment(); list.add(headLine); list.add(blog); list.add(sports); list.add(scientistFragment); list.add(economicsFragment); list.add(videoFragment); list.add(entertainmentFragment); list.add(readingFragment); list.add(femaleFragment); list.add(maleFragment); list.add(militaryFragment); list.add(carsFragment); list.add(educationFragment); list.add(houseFragment); list.add(gamesFragment); list.add(constellationFragment); } private View getTabItemView(int i){ View view = LayoutInflater.from(MainActivity.this).inflate(R.layout.fragment_tabhost_content_main,null); TextView tv = (TextView) view.findViewById(R.id.tabhost_text); tv.setText(titles[i]); return view; } private class MainActivityFragmentPagerAdapter extends FragmentPagerAdapter{ public MainActivityFragmentPagerAdapter(FragmentManager fm){ super(fm); } @Override public Fragment getItem(int position) { return list.get(position); } @Override public int getCount() { return list.size(); } } } ``` activity_main.xml内容如下: ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context="com.wolfgy.news.newsclient.MainActivity"> <android.support.v4.app.FragmentTabHost android:id="@+id/main_fragmentTabHost" android:layout_width="match_parent" android:layout_height="wrap_content"> </android.support.v4.app.FragmentTabHost> <android.support.v4.view.ViewPager android:id="@+id/main_viewPager" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> ```

android:从Activity跳转到另一个Activity的Fragment的时候程序报错。

以下是报错信息: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.whut.imageencryptionapp, PID: 31941 java.lang.RuntimeException: **Unable to instantiate activity ComponentInfo****{com.whut.imageencryptionapp/com.whut.imageencryptionapp.ui.ImageHandleActivity}: **java.lang.ClassCastExceptio**n: com.whut.imageencryptionapp.ui.ImageHandleActivity **cannot be cast to android.app.Activity ** at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3678) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3939) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2373) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:8147) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) Caused by: java.lang.ClassCastException: com.whut.imageencryptionapp.ui.ImageHandleActivity cannot be cast to android.app.Activity at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95) at android.support.v4.app.CoreComponentFactory.instantiateActivity(CoreComponentFactory.java:43) at android.app.Instrumentation.newActivity(Instrumentation.java:1257) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3663) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3939)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)  at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)  at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2373)  at android.os.Handler.dispatchMessage(Handler.java:107)  at android.os.Looper.loop(Looper.java:213)  at android.app.ActivityThread.main(ActivityThread.java:8147)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)  DeImagePickActivity相关代码如下: ``` case R.id.iv_image_show_activity_back: /* Intent intent = new Intent(this, ImageHandleActivity.class); startActivity(intent); FragmentManager fragmentManager; Fragment fragment = new ImageHandleActivity(); fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.rl_fragment1, fragment).commit(); fragmentTransaction = fragmentManager.beginTransaction(); ImageHandleActivity imageHandleActivity = new ImageHandleActivity(); fragmentTransaction.replace(R.id.ll_de, imageHandleActivity).commit(); */ ImageHandleActivity imageHandleActivity = new ImageHandleActivity(); FragmentManager fragmentManager; fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.rl_fragment1,imageHandleActivity).commit(); Intent intent = new Intent(this,ImageHandleActivity.class); startActivity(intent); ``` 注释中都是我尝试过的方法,但是还是会出现异常。 我要从DeImagePickActivity跳转到ImageHandleActivity,其中ImageHandleActivity继承了Fragment,他的Activity是MainActivity。 感谢解答!

android app出现这个奔溃

大家好,用addr2line工具也查不到是so哪行代码出现的问题,这是不是java层奔溃导致的? 06-07 09:01:54.449 10949-10949/com.wl.andrpeer A/libc: heap corruption detected by dlmalloc 06-07 09:01:54.449 10949-10949/com.wl.andrpeer A/libc: Fatal signal 6 (SIGABRT) at 0x00002ac5 (code=-6), thread 10949 (com.wl.andrpeer) 06-07 09:01:54.504 2434-2434/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 06-07 09:01:54.504 2434-2434/? I/DEBUG: Build fingerprint: 'Huawei/PE-TL20/hwPE:4.4.2/HuaweiPE-TL20/CHNC00B200:user/ota-rel-keys,release-keys' 06-07 09:01:54.504 2434-2434/? I/DEBUG: Revision: '0' 06-07 09:01:54.504 2434-2434/? I/DEBUG: pid: 10949, tid: 10949, name: com.wl.andrpeer >>> com.wl.andrpeer <<< 06-07 09:01:54.504 2434-2434/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- 06-07 09:01:54.504 2434-2434/? I/DEBUG: Abort message: 'heap corruption detected by dlmalloc' 06-07 09:01:54.649 2434-2434/? I/DEBUG: r0 00000000 r1 00002ac5 r2 00000006 r3 00000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: r4 00000006 r5 0000000b r6 00002ac5 r7 0000010c 06-07 09:01:54.649 2434-2434/? I/DEBUG: r8 be85d330 r9 6d4aed20 sl 00000000 fp be85d344 06-07 09:01:54.649 2434-2434/? I/DEBUG: ip 00000000 sp be85d1f0 lr 400a3271 pc 400b21b0 cpsr 000f0010 06-07 09:01:54.649 2434-2434/? I/DEBUG: d0 636f6c6c616d6c64 d1 65746564206e6f69 06-07 09:01:54.649 2434-2434/? I/DEBUG: d2 0074006300410061 d3 0074006900760070 06-07 09:01:54.649 2434-2434/? I/DEBUG: d4 0000000000000000 d5 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d6 0000000000000000 d7 0000000080000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d8 0000000043ac8000 d9 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d10 0000000000000000 d11 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d12 0000000000000000 d13 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d14 0000000000000000 d15 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d16 ffffffffffffffff d17 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d18 000000010bbfe000 d19 00000000000001a8 06-07 09:01:54.649 2434-2434/? I/DEBUG: d20 0000000000000098 d21 0000000000800000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d22 00000000008bb688 d23 0000000080c32cc0 06-07 09:01:54.649 2434-2434/? I/DEBUG: d24 0000000080c32cc1 d25 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d26 3ff0000000000000 d27 0000000000000000 06-07 09:01:54.649 2434-2434/? I/DEBUG: d28 3ff0000000000000 d29 0000000000000001 06-07 09:01:54.649 2434-2434/? I/DEBUG: d30 0000000000000001 d31 0000000080c34640 06-07 09:01:54.654 2434-2434/? I/DEBUG: scr 60000010 06-07 09:01:54.659 2434-2434/? I/DEBUG: backtrace: 06-07 09:01:54.659 2434-2434/? I/DEBUG: #00 pc 000221b0 /system/lib/libc.so (tgkill+12) 06-07 09:01:54.659 2434-2434/? I/DEBUG: #01 pc 0001326d /system/lib/libc.so (pthread_kill+48) 06-07 09:01:54.659 2434-2434/? I/DEBUG: #02 pc 00013481 /system/lib/libc.so (raise+10) 06-07 09:01:54.659 2434-2434/? I/DEBUG: #03 pc 000121b7 /system/lib/libc.so 06-07 09:01:54.659 2434-2434/? I/DEBUG: #04 pc 00021a64 /system/lib/libc.so (abort+4) 06-07 09:01:54.659 2434-2434/? I/DEBUG: #05 pc 00012c9d /system/lib/libc.so 06-07 09:01:54.659 2434-2434/? I/DEBUG: #06 pc 0000f3bd /system/lib/libc.so 06-07 09:01:54.659 2434-2434/? I/DEBUG: #07 pc 000102c1 /system/lib/libc.so (dlmalloc+604) 06-07 09:01:54.659 2434-2434/? I/DEBUG: #08 pc 0000de9b /system/lib/libc.so (malloc+10) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #09 pc 000205fd /system/lib/libbinder.so (android::Parcel::continueWrite(unsigned int)+352) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #10 pc 00020d2f /system/lib/libbinder.so (int android::Parcel::writeAligned<unsigned int>(unsigned int)+36) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #11 pc 00020f9d /system/lib/libbinder.so (android::Parcel::writeInterfaceToken(android::String16 const&)+20) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #12 pc 0006e1ef /system/lib/libandroid_runtime.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: #13 pc 0001eb8c /system/lib/libdvm.so (dvmPlatformInvoke+112) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #14 pc 0004f273 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #15 pc 00027fa0 /system/lib/libdvm.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: #16 pc 0002f130 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #17 pc 0002c794 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #18 pc 00061a09 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+392) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #19 pc 00069b17 /system/lib/libdvm.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: #20 pc 00027fa0 /system/lib/libdvm.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: #21 pc 0002f130 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #22 pc 0002c794 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #23 pc 00061725 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #24 pc 0004ae3b /system/lib/libdvm.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: #25 pc 00050697 /system/lib/libandroid_runtime.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: #26 pc 0005145f /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+386) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #27 pc 0000105b /system/bin/app_process 06-07 09:01:54.664 2434-2434/? I/DEBUG: #28 pc 0000e5ef /system/lib/libc.so (__libc_init+50) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #29 pc 00000d7c /system/bin/app_process 06-07 09:01:54.664 2434-2434/? I/DEBUG: stack: 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1b0 28e0001d 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1b4 4158e69b /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, _jobject*)+34) 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1b8 28e0001d 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1bc be85d1e4 [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1c0 28e0001d 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1c4 4157ca6d /system/lib/libdvm.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1c8 be85d2e4 [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1cc 4157cc79 /system/lib/libdvm.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1d0 00000000 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1d4 4009deb1 /system/lib/libc.so (free+12) 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1d8 400df38c 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1dc 768dd3fb /data/app-lib/com.wl.andrpeer-1/libp2p-lib.so 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1e0 be85d2d0 [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1e4 be85d2dc [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1e8 be85d2d8 [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1ec be85d2e4 [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: #00 be85d1f0 00000006 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1f4 0000000b 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1f8 00002ac5 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d1fc 00000000 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d200 00000000 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d204 400a3271 /system/lib/libc.so (pthread_kill+52) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #01 be85d208 00000006 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d20c 00000000 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d210 7a4a9b30 [anon:libc_malloc] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d214 400a3485 /system/lib/libc.so (raise+14) 06-07 09:01:54.664 2434-2434/? I/DEBUG: #02 be85d218 be85d224 [stack] 06-07 09:01:54.664 2434-2434/? I/DEBUG: be85d21c 400a21bb /system/lib/libc.so

Incompatible types问题

import android.app.ListFragment; import android.os.Bundle; import android.widget.ArrayAdapter; public class DingdanFragment extends ListFragment { private String[] data; public static DingdanFragment fragment; @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Bundle bundle=getArguments(); data=bundle.getStringArray("data"); ArrayAdapter<String> adapter=new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,data); setListAdapter(adapter); } public static DingdanFragment getInstance(String[] data){ fragment=new DingdanFragment(); Bundle bundle=new Bundle(); bundle.putStringArray("data",data); fragment.setArguments(bundle); return fragment; } } import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import com.zhengjie.nhsoft_544.xiaoqianzhifu.R; import com.zhengjie.nhsoft_544.xiaoqianzhifu.base.BaseActivity; import com.zhengjie.nhsoft_544.xiaoqianzhifu.fragment.DingdanFragment; import java.util.ArrayList; import java.util.List; public class DingdanActivity extends BaseActivity { private List<DingdanFragment> fragments=new ArrayList<>(); private ViewPager pager; @Override protected void loadXml() { setContentView(R.layout.activity_dingdan); } @Override protected void initView() { pager=(ViewPager)findViewById(R.id.vp_dingdan); MyAdapter adapter=new MyAdapter(getSupportFragmentManager()); pager.setAdapter(adapter); } @Override protected void setListener() { } @Override protected void initData() { String[] data1=getResources().getStringArray(R.array.arr1); DingdanFragment fragment1=DingdanFragment.getInstance(data1); String[] data2=getResources().getStringArray(R.array.arr2); DingdanFragment fragment2=DingdanFragment.getInstance(data2); String[] data3=getResources().getStringArray(R.array.arr3); DingdanFragment fragment3=DingdanFragment.getInstance(data3); fragments.add(fragment1); fragments.add(fragment2); fragments.add(fragment3); } class MyAdapter extends FragmentPagerAdapter{ public MyAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { return fragments.get(position); } @Override public int getCount() { return fragments.size(); } } } 然后![图片说明](https://img-ask.csdn.net/upload/201607/28/1469675615_952058.png)。。哪位大神能说下怎么解决吗?

关于报错闪退的问题?有没有大神来看一眼。。。。

这是我做柱状图的代码 ``` package com.chenxi.bimquanziguankong.fragment; import android.content.Context; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.RelativeLayout; import com.alibaba.fastjson.JSON; import com.blankj.utilcode.util.ToastUtils; import com.chenxi.bimquanziguankong.R; import com.chenxi.bimquanziguankong.appConst.AppConst; import com.chenxi.bimquanziguankong.application.MyApplication; import com.chenxi.bimquanziguankong.common.StringAxisValueFormatter; import com.chenxi.bimquanziguankong.entity.InvestmentControlClass; import com.chenxi.bimquanziguankong.view.LineChart02View; import com.chenxi.bimquanziguankong.view.MyMarkerView; import com.github.mikephil.charting.charts.CombinedChart; import com.github.mikephil.charting.components.AxisBase; import com.github.mikephil.charting.components.XAxis; import com.github.mikephil.charting.components.YAxis; import com.github.mikephil.charting.data.BarData; import com.github.mikephil.charting.data.BarDataSet; import com.github.mikephil.charting.data.BarEntry; import com.github.mikephil.charting.data.CombinedData; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import com.github.mikephil.charting.formatter.IAxisValueFormatter; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; import okhttp3.Call; import okhttp3.Callback; import okhttp3.Request; import okhttp3.Response; public class InvestmentAmountControlFragment extends BaseFragment { private View mView; RelativeLayout rl_document_list_is_null; private CombinedChart combineChart; List<InvestmentControlClass> investmentControlClasses = new ArrayList<>(); private List<String> xAxisValues = new ArrayList<>(); XAxis xAxis; YAxis axisLeft; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.fragment_new_investment_amount_control, container, false); initView(mView); getxAxisValuesData(); getyAxisValuesData(); MyMarkerView myMarkerView = new MyMarkerView(getActivity(), R.layout.custom_marker_view); myMarkerView.setChartView(combineChart); combineChart.setMarker(myMarkerView); return mView; } private void initView(View mView) { rl_document_list_is_null = mView.findViewById(R.id.rl_document_list_is_null); combineChart = mView.findViewById(R.id.combineChart); combineChart.setDrawBorders(true); // 显示边界 combineChart.getDescription().setEnabled(false); // 不显示备注信息 combineChart.setPinchZoom(true); // 比例缩放 } private void getxAxisValuesData() { String url = AppConst.innerIp + "/api/" + AppConst.getProjectID() + "/InvestmentControlClass"; Request request = new Request.Builder() .url(url) .build(); MyApplication.getOkHttpClient().newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { ToastUtils.showShort("数据请求失败"); } @Override public void onResponse(Call call, Response response) throws IOException { if (response.code() == 200) { try { String responseData = response.body().string(); investmentControlClasses = JSON.parseArray(responseData, InvestmentControlClass.class); if (investmentControlClasses.size()!=0){ for (int i = 0; i < investmentControlClasses.size(); i++) { xAxisValues.add(investmentControlClasses.get(i).getName()); } } xAxis = combineChart.getXAxis(); xAxis.setDrawGridLines(false); /*解决左右两端柱形图只显示一半的情况 只有使用CombinedChart时会出现,如果单独使用BarChart不会有这个问题*/ xAxis.setAxisMinimum(-0.5f); xAxis.setAxisMaximum(xAxisValues.size() - 0.5f); xAxis.setGranularity(1f); xAxis.setLabelCount(xAxisValues.size()); // 设置X轴标签数量 xAxis.setPosition(XAxis.XAxisPosition.BOTTOM); // 设置X轴标签位置,BOTTOM在底部显示,TOP在顶部显示 xAxis.setValueFormatter(new StringAxisValueFormatter(xAxisValues)); axisLeft = combineChart.getAxisLeft(); // 获取左边Y轴操作类 axisLeft.setAxisMinimum(0); // 设置最小值 axisLeft.setGranularity(10); // 设置Label间隔 axisLeft.setLabelCount(10); }catch (IOException e){ e.printStackTrace(); } } else { ToastUtils.showShort("数据请求出错!500"); } } }); } private void getyAxisValuesData() { String url = AppConst.innerIp + "/api/" + AppConst.getProjectID() + "/Report/InvestmentControl"; //请求数据 Request fileRrequest = new Request.Builder() .url(url) .build(); Log.e("TAG", "柱状图地址 "+fileRrequest ); MyApplication.getOkHttpClient().newCall(fileRrequest).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { ToastUtils.showShort("数据请求失败"); } @Override public void onResponse(Call call, Response response) throws IOException { if (response.code() == 200) { String responseData = response.body().string(); getActivity().runOnUiThread(new Runnable() { @Override public void run() { JSONArray jsonArray = null; try { jsonArray = new JSONArray(responseData); //获取柱状图数组 List<BarEntry> barEntries = new ArrayList<>(); List<Entry> lineEntry = new ArrayList<>(); if (xAxisValues.size()!=0){ for (int i = 0; i < xAxisValues.size(); i++) { List<String> list = new ArrayList<>(); for (int j = 0; j < jsonArray.length(); j++) { JSONObject jo = new JSONObject(jsonArray.get(j).toString()); if (i > 0) { list.add(jo.getString(xAxisValues.get(i))); } } String[] ary = list.toArray(new String[list.size()]); float a[] = new float[ary.length]; for (int x = 0; x < ary.length; x++) { a[x] = Float.parseFloat(ary[x]); } barEntries.add(new BarEntry(i, a)); float sum = 0; for (int z = 0; z < a.length; z++) { sum = sum + a[z]; } lineEntry.add(new Entry(i, sum)); } } //柱状图数据 BarDataSet barDataSet = new BarDataSet(barEntries, ""); barDataSet.setColors(Color.parseColor("#ae312e"), Color.parseColor("#2a3f4e"), Color.parseColor("#579199") , Color.parseColor("#be765d"), Color.parseColor("#82b49e")); BarData barData = new BarData(); barData.addDataSet(barDataSet); //折线图数据 LineDataSet lineDataSet = new LineDataSet(lineEntry, "总和"); lineDataSet.setColor(Color.parseColor("#b71c1c")); lineDataSet.setCircleColor(Color.parseColor("#b71c1c")); lineDataSet.setValueTextColor(Color.parseColor("#f44336")); lineDataSet.setLineWidth(3f); lineDataSet.setHighlightEnabled(false); LineData lineData = new LineData(); lineData.addDataSet(lineDataSet); //组和图数据 CombinedData combinedData = new CombinedData(); // 创建组合图的数据源 combinedData.setData(barData); // 添加柱形图数据源 combinedData.setData(lineData); // 添加折线图数据源 combineChart.setData(combinedData); // 为组合图设置数据源 combineChart.invalidate(); } catch (JSONException e1) { e1.printStackTrace(); } } }); } else { ToastUtils.showShort(response.message()); } } }); } } ``` 然后偶然会出现闪退的现象报错信息如下有大神帮忙看下吗感激不尽 loge报错信息 ``` 07-17 16:03:30.221 13514-13514/com.chenxi.bimquanziguankong E/CrashHandler: In thread: Thread[main,5,main] UncaughtException detected: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at com.github.mikephil.charting.data.DataSet.getEntryForIndex(DataSet.java:286) at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:184) at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:547) at com.github.mikephil.charting.renderer.CombinedChartRenderer.drawValues(CombinedChartRenderer.java:96) at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:264) at android.view.View.draw(View.java:15231) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15234) at android.widget.FrameLayout.draw(FrameLayout.java:598) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15234) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2554) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2376) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2006) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1085) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5909) at android.view.C 07-17 16:03:30.247 13514-13514/com.chenxi.bimquanziguankong E/AndroidRuntime: FATAL EXCEPTION: main Process: com.chenxi.bimquanziguankong, PID: 13514 java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0 at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255) at java.util.ArrayList.get(ArrayList.java:308) at com.github.mikephil.charting.data.DataSet.getEntryForIndex(DataSet.java:286) at com.github.mikephil.charting.utils.Transformer.generateTransformedValuesLine(Transformer.java:184) at com.github.mikephil.charting.renderer.LineChartRenderer.drawValues(LineChartRenderer.java:547) at com.github.mikephil.charting.renderer.CombinedChartRenderer.drawValues(CombinedChartRenderer.java:96) at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:264) at android.view.View.draw(View.java:15231) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15234) at android.widget.FrameLayout.draw(FrameLayout.java:598) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14162) at android.view.View.getDisplayList(View.java:14189) at android.view.View.draw(View.java:14959) at android.view.ViewGroup.drawChild(ViewGroup.java:3405) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15234) at android.view.View.updateDisplayListIfDirty(View.java:14167) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3389) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3368) at android.view.View.updateDisplayListIfDirty(View.java:14127) at android.view.View.getDisplayList(View.java:14189) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318) at android.view.ViewRootImpl.draw(ViewRootImpl.java:2554) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2376) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2006) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1085) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5909) ```

更新后出现CastException

更新框架: @Override public int getItemPosition(Object object) { FragmentPage2 f = (FragmentPage2) object; if (f != null) { f.update(); } return super.getItemPosition(object); } 现在如果添加一个额外的`Fragment`到`getItem(int position)`中,还一切正常,但是一运行`mPager.getAdapter().notifyDataSetChanged();`,就会报出异常: 08-07 19:45:50.844: E/AndroidRuntime(17776): java.lang.ClassCastException: com.foodbuilder.FragmentPage1 cannot be cast to com.foodbuilder.FragmentPage2 08-07 19:45:50.844: E/AndroidRuntime(17776): at com.foodbuilder.MainActivity$MyAdapter.getItemPosition(MainActivity.java:967) 08-07 19:45:50.844: E/AndroidRuntime(17776): at android.support.v4.view.ViewPager.dataSetChanged(ViewPager.java:851) 08-07 19:45:50.844: E/AndroidRuntime(17776): at android.support.v4.view.ViewPager$PagerObserver.onChanged(ViewPager.java:2772) 08-07 19:45:50.844: E/AndroidRuntime(17776): at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37) 08-07 19:45:50.844: E/AndroidRuntime(17776): at android.support.v4.view.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:276) 08-07 19:45:50.844: E/AndroidRuntime(17776): at com.foodbuilder.MainActivity.onDialogPositiveClick(MainActivity.java:888) 08-07 19:45:50.844: E/AndroidRuntime(17776): at com.foodbuilder.TablesDialogFragment$2.onClick(TablesDialogFragment.java:57) 08-07 19:45:50.844: E/AndroidRuntime(17776): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166) `

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

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

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

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

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

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

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

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

将一个接口响应时间从2s优化到 200ms以内的一个案例

一、背景 在开发联调阶段发现一个接口的响应时间特别长,经常超时,囧… 本文讲讲是如何定位到性能瓶颈以及修改的思路,将该接口从 2 s 左右优化到 200ms 以内 。 二、步骤 2.1 定位 定位性能瓶颈有两个思路,一个是通过工具去监控,一个是通过经验去猜想。 2.1.1 工具监控 就工具而言,推荐使用 arthas ,用到的是 trace 命令 具体安装步骤很简单,大家自行研究。 我的使用步骤是...

学历低,无法胜任工作,大佬告诉你应该怎么做

微信上收到一位读者小涛的留言,大致的意思是自己只有高中学历,经过培训后找到了一份工作,但很难胜任,考虑要不要辞职找一份他能力可以胜任的实习工作。下面是他留言的一部分内容: 二哥,我是 2016 年高中毕业的,考上了大学但没去成,主要是因为当时家里经济条件不太允许。 打工了三年后想学一门技术,就去培训了。培训的学校比较垃圾,现在非常后悔没去正规一点的机构培训。 去年 11 月份来北京找到了一份工...

JVM内存结构和Java内存模型别再傻傻分不清了

JVM内存结构和Java内存模型都是面试的热点问题,名字看感觉都差不多,网上有些博客也都把这两个概念混着用,实际上他们之间差别还是挺大的。 通俗点说,JVM内存结构是与JVM的内部存储结构相关,而Java内存模型是与多线程编程相关,本文针对这两个总是被混用的概念展开讲解。 JVM内存结构 JVM构成 说到JVM内存结构,就不会只是说内存结构的5个分区,而是会延展到整个JVM相关的问题,所以先了解下

和黑客斗争的 6 天!

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

Google 与微软的浏览器之争

浏览器再现“神仙打架”。整理 | 屠敏头图 | CSDN 下载自东方 IC出品 | CSDN(ID:CSDNnews)从 IE 到 Chrome,再从 Chrome 到 Edge,微软与...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

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

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

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

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

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

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

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

面试:第十六章:Java中级开发(16k)

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

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

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

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

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

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

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

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

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

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

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

立即提问
相关内容推荐