Android错误tv_view [英] Android error tv_view

查看:90
本文介绍了Android错误tv_view的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循本教程:

http://www.codeproject.com/Articles/102065/Android-A-beginner-s-guide?fid=1583614&df=10000&mpp=50&prof=False&sort=Position&view=Normal&spc=Relaxed&fr=51#xx0xx





但我收到此错误:



But i get this error:

Error:(21, 61) error: cannot find symbol variable tv_View





这是



This is the full code of that

package com.example.*.helloworld;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.TextView;

public class HelloWorld extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hello_world);
        final TextView tv_View = (TextView)findViewById(R.id.tv_View);
        final EditText et_Text = (EditText)findViewById(R.id.et_Text);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_hello_world, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}





我的尝试:



不同的东西,最简单的事情:在google上搜索。



What I have tried:

Different things, the most simple thing: Searching on google.

推荐答案

final TextView tv_View = (TextView)findViewById(R.id.tv_View);



错误消息告诉您问题出在第21行,从字符位置61开始,这是id值 tv_View 在上面一行。



因此,您的XML出错,或者对象名称错误,或者XML没有为其他人编译原因。检查源代码以查看错误。


The error message tells you the problem is on line 21 starting at character position 61, which is the id value tv_View on the above line.

So, either your XML is in error, or the object is misnamed, or the XML did not compile for some other reason. Check your source code to see what is wrong.


这篇关于Android错误tv_view的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆