当我将活动更改为片段时,我想修改String数组资源ID错误

时间:2016-05-03 07:54:12

标签: android-activity fragment

当我将活动更改为片段时,我有一个'线程退出未捕获的异常'错误。但是,我无法解决问题。帮帮我。

enter image description here

这是错误消息。

这是java代码

    int resId = getResources().getIdentifier("Data_" + data, "array", getActivity().getPackageName());
    String[] arData = getResources().getStringArray(resId);

    TextView txtTitle = (TextView) view.findViewById(R.id.txtTitle);
    txtTitle.setText(String.valueOf(arData[0]));

    ImageView image = (ImageView) view.findViewById(R.id.image);
    image.setImageResource(getResources().getIdentifier("image_" + getActivity().getIntent().getStringExtra("Data"), "drawable", getActivity().getPackageName()));
//  image.setImageResource(getResources().getIdentifier("image_" + getArguments().getString("Data"), "drawable", getActivity().getPackageName()));

    TextView txtTitle2 = (TextView) view.findViewById(R.id.txtTitle2);
    txtTitle2.setText(String.valueOf(arData[1]));
    txtTitle2.setMovementMethod(new ScrollingMovementMethod());

    TextView txtContent = (TextView) view.findViewById(R.id.txtContent);
    txtContent.setText(String.valueOf(arData[2]));
    txtContent.setMovementMethod(new ScrollingMovementMethod());

0 个答案:

没有答案