"The method findViewById(int) is undefined for ..."

Pythia: A Customizable Hardware Prefetching Framework Using Online Reinforcement Learning——“预取”论文解读 参考传送门: 1. Hardware Prefetching笔记 2. 全球百科——缓存预取 3. 百度百科——缓存数据预期技术 目录0. 什么是Hardware Prefetching(本节内容不包括在论文中)1. 简介1.1 关于Hardware Prefetching的一些关键信息1.2 现阶段方法的缺陷1.3 论文团队的目标1.4 核心思想2. 必要的背景知识介绍2.1 强化学习(Reinforcement learning)2.2 为什么说强化学习是一个好的解决思路3. 解决方法与思路3.1 Py 阅读详情

转自http://www.anddev.org/-und-quotthe_method_findviewbyidint_is_undefined_for_-und-quot-t11806.html

my main class that the wizard set up for me, but i wanted to simplify the code by making all its actions in a new class.

I made the new class, and when i try to assign a TextView to a variable ...

example :

Syntax: [ Download ] [ Hide ]
Syntax: [ Download ] [ Show ]
Using java Syntax Highlighting
  1. tv = (TextView )findViewById (R. id. TextView01 ) ;
Parsed in 0.030 seconds, using GeSHi 1.0.8.4



i get the error:

The method findViewById(int) is undefined for the type newClass



I can make the error go away by making

Code: Select all
public class newClass [b]extends activity[/b]



but that gives me force close errors when i start the app. I am a novice programmer, but I am so confused, please help! :)

gooberguy
Junior Developer
Junior Developer
 
Posts: 20
Joined: Thu Mar 04, 2010 7:45 am


Top




Top


Postby senormoll » Sat Mar 06, 2010 8:10 pm

It's difficult without seeing all of your code, please post a larger portion of it.

Just to speculate on some issues for now:
1) make sure your "main" class does extend Activity
2) make sure there is an element in main.xml or whatever layout you're using with the id TextView01
3) make sure you declare the element tv as a textview

So

public class MyClass extends Activity {

private TextView tv;
...
tv = (TextView) findViewById(R.id.TextView01);
}


Since you said you created your own class, I have a feeling it's one of those three issues.

一文读懂 CST 时/频域求解器 本文系统介绍了CST Studio Suite中的关键网格技术——六面体网格、四面体网格以及TLM求解器专用的八叉树非均匀网格技术。重点阐述了六面体网格的三项核心技术:理想边界拟合(PBA)技术可精确处理曲面边界,薄片技术(TST)能高效模拟薄层结构,自适应八叉树网格实现计算资源最优分配。同时详细对比了六面体网格与四面体网格的特点及适用场景,前者适用于系统级EMC/EMI分析等时域问题,后者擅长处理复杂曲面和异质材料的频域问题。 阅读详情

相关推荐

物联网通信中NB-IoT、Cat.1、LTE-M该如何选择?

首先我们要确定我们产品的关键需求,例如:我们的设备是否对数据传输速率有较高的要求,有较高要求我们就需要选择较高传输速率的Cat.1来开发我们的产品。同时关于产品性能方面,我们对功耗、延迟、可靠性也会有所要求,例如我们的产品为移动端产品,不方便布线以及安装电源,那我们就会采用电池供电的方式,所以在选择时可以优先考虑低功耗产品,最终结合其他需求选择出合适的协议。首先,我们需求的产品是不同的,我们需要根据产品需求或项目需求来进行选择,NB-IoT、Cat.1、Cat.M都有属于自己的优势。

a1809032425的博客 1190

android-The method findViewById(int) is undefined for the type ContactMainFragment报错

@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mTitleNameView = (TextView) fi...

angen3675的博客 321

Plant Simulation 双深位立库开发系列教程-货架参数化

为了方便用户进行货架参数化,我们需要在交互界面上进行参数调整,右键打开RackLane,打开Dialog,在Rack_tab的tab下创建相应的对象,并创建NumberOfRightRack和NumberOfLeftRack作为数据连接对象。通过Rack._3D.VisibleGraphicGroups := ["default"]来切换需要显示的Rack,当不需要显示则可以Rack._3D.VisibleGraphicGroups := [""]即可。首先,加载默认的HBW库到模型中,确保结构树当中有。

santayana的专栏 1226

android常见错误(实时更新)

学习安卓有小段时日啦,为了避免总是遇到相应的错误,特此做了这个小记录。。。。赏脸围观吧。   1.xml aborting build  :架构错误, 在布局时的常见错误xml缺少标签或者符号 2.Error: No resource found that matches the given name (at 'background' with value '@drawable/S5091

zhuruicheng的博客 1015

android函数未定义,android – 方法findViewById(int)未定义

我是Android开发的新手,我正在尝试编写一个小应用程序,它允许我获取外部JSON文件并解析它.我得到了它的工作,但如果我尝试在后台执行它作为AsyncTask它不会工作. Eclipse给了我错误The method findViewById(int) is undefined for the type LongOperation在这一行:TextView txtView1 = (TextVi...

weixin_39894914的博客 299

android函数未定义,android – 方法findViewById(int)未定义类型

我收到了错误The method findViewById(int) is undefined for the type PM_section在尝试实现我的可扩展ListView时.我确信这是一个常见的错误,但我找不到解决方案.我试图学习碎片等等,自从我开始以来,它一直是一场艰苦的战斗.我做了很多搜索,发现了很多结果,在我的情况下似乎没有帮助我.如果有人能给我任何见解,或指出我正确的方向,我将非常...

weixin_30290673的博客 413

Android Studio编译失败:对findViewById的引用不明确

Android Studio编译报错: 错误: 对findViewById的引用不明确 Activity 中的方法 findViewById(int) 和 AppCompatActivity 中的方法 <T>findViewById(int) 都匹配 其中, T是类型变量: T扩展已在方法 <T>findViewById(int)中声明的View...

蓝不蓝编程 9476

The method findViewById(int) is undefined for the type FragmentHome报错

很简单的一个TextView初始化,但是去会报错,解决方法加上view,如下: View view = inflater.inflate(R.layout.home_index, null); //获取数据并且显示 topCity = (TextView)findViewById(R.id.index_top_city); topCity = (TextView)view.f

liuy0202的博客 2891

fragment 里需要activity。Android-The method findViewById(int) is undefined for the type first (Fragment)

部分参考:  http://stackoverflow.com/questions/20981487/android-the-method-findviewbyidint-is-undefined-for-the-type-first-fragment/20981583 I'm new to fragments and i'm developing an application

qing101hua的专栏 2273

Android中通过泛型解决findViewById需要强制类型转换的问题

参考: Android开发小窍门通过泛型简化findViewById类型转换 定义方法 public class BaseActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceStat...

火星男孩的分享空间 1434

安卓启动流程与期间核心组件工作原理

本文以实际工作中出现的启动相关各种千奇百怪的bug为钩子,讲解了安卓app冷启动过程中核心组件的工作原理,pms -> packageParser/androidmanifest.xml -> context -> ams -> application -> activity -> layoutInflater资源加载过程 -> wms /window/WM -> view与viewgroup绘制原理 -> 渲染阶段。理供解决问题的思路,看业务框架代码能看懂他们改的哪块源码,跟他们扯皮能扯赢

mix39的博客 313

15_09_09 The method computeResult() is undefined for the type MainActivity(未定义异常)

在使用方法时,有时出现如下异常 它的错误提示为 也就是说在使用这个方法时,必须先声明: 这样就可以使用了

牧渔的博客 470

Android 简化findViewById写法

今天给大家分享一下简化findViewById的写法, 大家在写代码的时候可能烦透了写 findViewById, 当然我们也可以利用相关注解框架来简写,比如ViewInject 去简化这个操作。 至于用ViewInject性能方面,这里不做介绍。 自定义一个ViewUtil类 public class ViewUtil { /** * activity.

爱开发 3090

The method setProgress(int, int, boolean) is undefined for the type NotificationCompat.Builder

原文提示错误: The method setProgress(int, int, boolean) is undefined for the type NotificationCompat.Builder 错误原因: 使用了低版本的v4支持包 解决办法: 网上下载一个新的v4包,或者到较新的SDK目录下拷贝,路径为"SDK路径\extras\android\suppo

zhjkenneth的专栏 2221

both method findViewById(int) in Activity and method <T>findViewById(int) in AppCompatActivity

error: reference to findViewById is ambiguous both method findViewById(int) in Activity and method <T>findViewById(int) in AppCompatActivity match where T is a type-variable: T extends Vie...

pang9998的博客 1279

(已解决)错误: 找不到符号 符号: 方法 findViewById(int)

findViewById(R.id.button0); 这东西只在activity中使用 在fragment中应该 getView().findViewById(R.id.button0);

kong_youqing的博客 1852

findViewById (int) in AppCompatActivity and findViewById (int) in Activity match

解决方法修改compileSdkVersion和buildToolsVersion升级到27

DingDong-IT 1104

土木工程毕业设计——【10层】十层框剪方型住宅楼(建筑图结构图计算书).zip

土木工程毕业设计——【10层】十层框剪方型住宅楼(建筑图结构图计算书).zip

cad工具焊缝绘制

CAD小工具加载在CAD中,输入W,进行焊缝的绘制

上一篇: android 布局总结
下一篇: 找回Ubuntu 13.04 ‘Backspace’键 的‘返回’功能
BeBeMo
博客等级 码龄14年 2粉丝 7原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值