Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法在setText解析符号_Android - Fatal编程技术网

Android 无法在setText解析符号

Android 无法在setText解析符号,android,Android,我想构建一个RSS阅读器,但是我在mRssFeed.setText(rssFeed)的onStart方法中遇到了一个“无法解析符号”错误,其中mRssFeed有问题。这是我的全班同学: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.f

我想构建一个RSS阅读器,但是我在
mRssFeed.setText(rssFeed)
的onStart方法中遇到了一个“无法解析符号”错误,其中mRssFeed有问题。这是我的全班同学:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.feed_fragment_portrait, container, false);
    TextView mRssFeed = (TextView) rootView.findViewById(R.id.rss_feed);
    return rootView;
}
@Override
public void onStart() {
    super.onStart();
    InputStream in = null;
    try {
        URL url = new URL("http://www.androidpit.com/feed/main.xml");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        in = conn.getInputStream();
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        for (int count; (count = in.read(buffer)) != -1; ) {
            out.write(buffer, 0, count);
        }
        byte[] response = out.toByteArray();
        String rssFeed = new String(response, "UTF-8");
        mRssFeed.setText(rssFeed);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

有人能帮我一下吗?

变量
mRSSfeed
onCreateView
中声明,因此
onStart
无法访问它

在类内的方法之外声明它,而不是像这样

TextView-mRssFeed

然后在
onCreateView
中将行更改为


mRssFeed=(TextView)rootView.findviewbyd(R.id.rss\u feed)

变量
mRSSfeed
onCreateView
中声明,因此
onStart
无法访问它

在类内的方法之外声明它,而不是像这样

TextView-mRssFeed

然后在
onCreateView
中将行更改为

mRssFeed=(TextView)rootView.findviewbyd(R.id.rss\u feed)

可能重复的可能重复的