奇怪的 rList 输出文件 Android Studio

问题描述

我目前正在 Android Studio 上构建情绪跟踪器和日记组合应用程序,但我遇到了这个特殊问题。每次我打开应用程序时,都会直接在应用程序的文件中弹出这个 rList 文件(这是我保存所有文本日记条目的地方) 这是我单击它时显示内容�� sr java.util.ArrayListx����a� I sizexp w t 2131165276x

我还没有看到过这样的问题。我只在饼图中使用数组列表,但我不知道为什么会出现这些数字和符号。另外我不知道为什么它被存储在fliesDir 唉,这是我的饼图代码

 private void addDataSet() {
        Log.d(TAG,"addDataSet started");
        ArrayList<PieEntry>  yEntrys = new ArrayList<>();
        ArrayList<String> xEntrys = new ArrayList<>();

        for(int i = 0; i < yData.length; i++){
            yEntrys.add(new PieEntry(yData[i],i));
        }

        for(int i = 1; i < xData.length; i++){
            xEntrys.add((xData[i]));
        }

        // create data set
        PieDataSet pieDataSet = new PieDataSet(yEntrys,"Elated");
        pieDataSet.setSliceSpace(2);
        pieDataSet.setValueTextSize(14);

        //add colors
        ArrayList<Integer> colors = new ArrayList<>();
        colors.add(Color.rgb(239,8,192));
        colors.add(Color.rgb(4,208,79));
        colors.add(Color.rgb(188,111,9));
        colors.add(Color.rgb(51,127,242));
        colors.add(Color.rgb(251,17));

        pieDataSet.setColors(colors);

        // add legend
        Legend legend = pieChart.getLegend();
        legend.setForm(Legend.LegendForm.CIRCLE);

        // create pie data object
        PieData pieData = new PieData(pieDataSet);
        pieChart.setData(pieData);
        pieChart.setUsePercentValues(true);
        pieChart.invalidate();

    }

其次是保存文本日记条目的代码

public void save(View v) {
        textPath = getApplication().getFilesDir().getAbsolutePath();
        SimpleDateFormat formatter = new SimpleDateFormat("MM_dd_yy",Locale.US);
        Date Now = new Date();
        textFile = inputTitle.getText().toString();
        String text = inputFeelings.getText().toString();
        FileOutputStream fos = null;
        try {
            fos = openFileOutput(textFile,MODE_PRIVATE);
            fos.write(text.getBytes());
            inputFeelings.getText().clear();
            Toast.makeText(this,"Saved to " + getFilesDir() + "/" + textFile,Toast.LENGTH_LONG).show();
        } catch (FileNotFoundException e) {
            e.printstacktrace();
        } catch (IOException e) {
            e.printstacktrace();
        } finally {
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printstacktrace();
                }
            }
        }
    }

我还在 viewPagerAdapter 中使用了 Arraylists,我认为这是导致此问题的实际原因,代码如下:

public class ViewPagerAdapter extends FragmentStatePagerAdapter {

    private List<Fragment> fragmentList = new ArrayList<>();
    private List<String> stringList = new ArrayList<>();


    public ViewPagerAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return stringList.get(position);

    }


    public void addFragment(Fragment fragment,String title){
        fragmentList.add(fragment);
        stringList.add(title);
    }

}

感谢任何形式的帮助。提前致谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)