Android问题集(五)——解决提示:The method **() is undefined for the type ***()

Photoscan+Smart3D+CC组合建模实战:如何用三款工具打造高精度实景模型 本文详细介绍了如何整合Photoscan、Smart3D和ContextCapture三款软件,构建高效高精度的实景三维建模工作流。通过利用Photoscan稳健的空三解算、Smart3D精准的刺点优化,以及ContextCapture强大的最终建模能力,该方案能有效应对复杂地形与海量数据,显著提升模型质量与生产效率,适用于测绘、文化遗产数字化等专业领域。 阅读详情

使用情景:在非Activity子类方法中,有时想要调用Activity类特有的方法,系统会提示无该方法The method is undefined。


思路
将Activity的父类Context作为方法参数,通过context调用该方法。


例一:在无继承类public class LostFocus{ }的方法linearLayoutLostFocus(final LinearLayout linearLayout)中,调用系统服务getSystemService隐藏输入法:

 InputMethodManager imm = 
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);

eclipse提示出错:
这里写图片描述

解决方法:将Activity作为方法形参——把方法linearLayoutLostFocus(final LinearLayout linearLayout)改写成
linearLayout(final LinearLayout linearLayout,final Context context),并将getSystemService()改写成context.getSystemService()即可解决问题。

完整linearLayoutLostFocus()方法详见:http://blog.csdn.net/youngwm/article/details/48165455


总结:遇到调用的方法(假设为:a())提示The method ** is undefined 时:
1、检查方法a()所在类(假设为:A.class)是否有被当前类引用
2、若没有,尝试将该方法(A.class)作为当前方法的参数,通过A.a()调用该方法。

PyTorch实战(2)——使用PyTorch构建神经网络 在本节中,我们使用 PyTorch 在简单数据集上构建了一个神经网络,训练神经网络来映射输入和输出,并通过执行反向传播来更新权重值以最小化损失值,并利用 Sequential 类简化网络构建过程;介绍了获取网络中间值的常用方法,以及如何使用 save、load 方法保存和加载模型,以避免再次训练模型。 阅读详情

相关推荐

第4章-07-将WebDriver获取的Cookie传递给Requests

在使用Selenium WebDriver获取了浏览器的Cookies之后,你可以将这些Cookies传递给requests库,以便在后续的HTTP请求中使用这些Cookies。这样做可以让你模拟浏览器会话,使得请求看起来像是从之前使用Selenium WebDriver控制的浏览器发出的。

黑夜开发者的博客 656

编译器报错The method XXX() is undefined for the type XXX的解决方案

构造方法调用同类中另一个同名构造方法,应使用this关键字

weixin_61964996的博客 3万+

NVIDIA Isaac Sim 入门教程(二)

Omniverse Isaac Sim 的工作空间非常容易自定义。调整用户界面的大小、停靠、取消停靠、添加和移除面板都非常容易。进入顶部菜单栏,单击下拉菜单最下方的窗口 > 视口 > 视口 2(现在工作区中应该会出现一个名为 "视口 2 "的新视口。如果您想创建更多的视口,请按照相机检查器扩展进行操作。单击并拖动视口 2 的顶部标题以激活停靠部件。拖放到原始视口的右侧,将两个视口并排放置。单击并向左拖动视口 2 的左侧,使视口大小相等。

机器人控制与仿真应用 6509

项目代码报:The method xx方法( ) is undefined for the type XX类

一般报这个错,三种情况: (1)导错包了,比如 本来导入第二个包,你却导入了第一个包。 这种错误好发现,因为编辑器会提示你,MapUtils cannot be resolved ,修改包即可。 (2)你虽然在项目中导入了这个jar包,但是当前版本的jar,不支持这个方法。                      明明导入了,怎么没

qq1164014750 15万+

报错:the method is undifined for the type

报错:the method is undifined for the type

qq_43118674的博客 2667

编译时The method is undefined for the type 报错

问题描述 : 项目使用 1.jdk1.8 2.maven管理引入很多第三方jar包依赖其中xml-apis.jar文件中自带了2002年的org.w3c.dom的jar文件(该jar文件中的Node接口没有getTextContent() ); 使用 org.w3c.dom.Node(在jdk的 rt.jar 中 原生api ) 报出 The method dosonme() is...

happyzxs的博客 3万+

java.lang.Error: Unresolved compilation problems: The method XXX is undefined for the type

java.lang.Error: Unresolved compilation problems: The method XXX is undefined for the type

lgq2941109633的博客 1334

android 6.0 The method sin(float) is undefined for the type FloatMath 报错

6.0 报错 The method sin(float) is undefined for the type FloatMath The method floor(float) is undefined for the type FloatMathAndroid6.0使用 Math.floor 代替 FloatMath.floor 即可,见下图: 解决方案是使用数学类:(float) Math

legend12300的专栏 4445

开发中碰到的问题:The method getSystemService(String) is undefined for the type CourseFragment

【问题】 android程序: ? 1 2 3 4 5 6 7 8 class UsbDeviceStateReceiver extends BroadcastReceiver{     public void onReceive(Context context, Intent intent) {         ...  

苦涩的风的博客 4472

The method getSupportFragmentManager() is undefined for the type

The method getSupportFragmentManager() is undefined for the type  出现这种情况的原因是,需要把继承Activity改成继承FragmentActivity public class MainActivity extends FragmentActivity {

子孟的博客 1758

The method getResources() is undefined for the type

在非activity的独立类中调用getResources()

zhangjikuan的专栏 7696

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

notification 报错the method build() is undefined for the type Notificatin.Builder

notification 报错the method build() is undefined for the type Notificatin.Builder 这事api版本太低导致的 Notifica没有builder方法解决方案,将项目api调整到 17 ok。

kan1kan5的专栏 3575

The method build() is undefined for the type Notification.Builder

安卓的模拟系统为Android 4.0.3(API 15)。在调试Notification出现如下错误提示:        The method build() is undefined for the type Notification.Builder        出现错误的部分源码如下: Intent intent = new Intent(MainActivity.this, O

qinjinghua2012的专栏 2182

The method getTextContent() is undefined for the type Element

如果你在编译Android项目的时候发生下面错误 The method getTextContent() is undefined for the typeElement, 一般原因是你选择了Android projecttarget版本太低,getTextContent()与setTextContent()是高版本Android的提供的,修改方法一是提升Android的版本,或者你可以用get

你系得嘎,加油 2104

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

关于The method getResources() is undefined for the type XX的问题处理

在遇见 The method getResources() is undefined for the type XX  是因为 在非activity中找不到可以传递的caves   现在需要在类里面 建立个 Context   然后getResources() private Context mContext; mContext.getResources.....

qq_30660895的博客 3418

Android:Java:编译/运行:提示:The method X is undefined for the type Y

编译/执行Y的时候,找不到X的实体; 1.必须在同一个类中 2.同一类中,X需写在Y之前

lovepet的专栏 3501

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

转自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 act

BeBeMo的博客 2502

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

Android错误:方法setListAdapter(ArrayAdapter<String>) is undefined for the type String

在写一个Android项目的时候      写了一句  setListAdapter()     但是 Eclipse却报错  提示是   The method setListAdapter(ArrayAdapter) is undefined for the type ... 然后自己就根据提示 百度了一下 问题的原因  和 解决方案  结果如下: 出问题

CallMeJason的专栏 2779

android开发:The method getSupportFragmentManager() is undefined for the type

问题出现情景: 代码如下:getSupportFragmentManager().beginTransaction().add(R.id.fragment, fragment).hide(fragment).commit();出现了“The method getSupportFragmentManager() is undefined”错误。解决方法: 需要实例化的activity必须 exten

shakdy的博客 536

fpga实现曼彻斯特编码

fpga实现曼彻斯特编码,包含源程序和实验报告。

ftp服务端程序vsftpd-2.2.2-24.el6.x86_64.rpm 以及ftp客户端 ftp-0.17-54.el6.x86_64.rpm

ftp服务端rpm安装包vsftpd-2.2.2-24.el6.x86_64.rpm以及ftp客户端程序ftp-0.17-54.el6.x86_64.rpm。亲测非常好用,rpm安装方便,使用便捷,版本为64位,用于centos6.5系统,centos7亲测同样可以使用~

上一篇: Android问题集(四)——EditText输入完毕后,击屏幕其它区域,隐藏/关闭输入法
下一篇: Android问题集(六)——Android工程文件夹带红色感叹号,展开工程无任何错误标志
youngwm
博客等级 码龄12年 10粉丝 20原创
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值