腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
2
回答
何时
在
活动
中
调用
findViewById
android
我有以下几行代码:domainSpinner.setVisibility(View.VISIBLE
在
GooglePlay
中
,我有时会收到错误报告,其中stackTrace
在
第二行给出了一个NullPointerException。所以一定是domainSpinner为空。我不知道为什么
findViewById
有时应该返回null。我试着往回走,转来转去...但是我从来没有遇到过这个问
浏览 0
提问于2017-07-07
得票数 1
回答已采纳
2
回答
我可以
在
实例字段
中
存储视图对象吗?
java
、
android
我要上
活动
课。如果能在onCreate中找到我需要的所有视图,然后
在
不
调用
findViewById
的情况下引用这些字段,那就太好了。但是这样做可以吗? 不能在运行时为视图分配不同的对象吗?例如,
findViewById
(res1) ==
findViewById
(res1)在任
何时
候都是真的吗?
浏览 0
提问于2011-07-02
得票数 2
回答已采纳
3
回答
为什么我
在
通过ID查找片段视图时获得空指针execepiton?
java
、
android
、
android-fragments
、
findviewbyid
ComponentInfo{com.example.dhruv.parqueue/com.example.dhruv.parqueue.UserProfile}:java.lang.RuntimeException:无法启动
活动
java.lang.NullPointerException:尝试
在
空对象引用上
调用
虚拟方法'android.view.View android.app.Dialog.
findViewById
(int)(R.id.imageView); pickImage = (
浏览 5
提问于2016-02-03
得票数 0
4
回答
从
活动
外部
调用
findViewById
()
android
、
view
、
android-activity
我正在创建一个Accordion类,并且需要访问该
活动
的一些UI元素。我将Activity的上下文传递给accordion类的构造函数,但Activity类只能使用
findViewById
API。我也不想传入我的
活动
的一个实例,因为这似乎因为潜在的内存泄漏而不被接受。
浏览 0
提问于2011-09-13
得票数 14
回答已采纳
1
回答
在
Activity.onCreate()
中
的setContentView()之后,Android什么时候会第一次
调用
View.onMeasure()?
android
、
view
、
lifecycle
假设一个Android
活动
为一个XML定义的布局
调用
setCurrentView(),其中包含一个或多个视图,以便以通常的方式绑定它: // ... other stuff MyCustomViewClass mcv = (MyCustomViewClass)
findViewById
mcv.setSomeValues(x,y,z)
浏览 2
提问于2018-01-31
得票数 0
回答已采纳
3
回答
Android:如何从片段
findViewById
()访问
活动
的视图(使用onCreateView)?
android
、
fragment
、
findviewbyid
我有一个非常简单的项目,其中有一个包含片段的
活动
。唯一您可能不熟悉的是,我使用的是一个,它并不是那么复杂,而且是我以前使用过的东西。这只是一个定制的网页浏览。; android:layout_height="fill_parent" /&
浏览 4
提问于2016-01-27
得票数 4
回答已采纳
2
回答
如何更改来自另一个
活动
的片段
中
TextView的文本
android
、
textview
、
fragment
、
android-fragmentactivity
我正在尝试从另一个
活动
中
更改片段布局
中
的TextView文本。我试着通过参考这个网站的老帖子来应用各种方法。但这些对我不起作用。 ((EditText
浏览 0
提问于2015-12-06
得票数 1
3
回答
在
android
中
启动
活动
的两种方式有什么不同
android
我无法理解
何时
使用这些方法。Button b = (Button)
findViewById
(R.id.btn); });Button b = (Button)
findViewById
); });我的另一个疑问是,当我使
浏览 0
提问于2012-02-01
得票数 0
2
回答
通过Mainactivity管理按钮可见性
java
、
android
、
android-fragments
嗨,我
在
创建一个管理片段
中
按钮的可见性并从Mainactivity管理它的方法方面遇到了问题,我尝试使用简单的.setVisibility,它返回了null对象的错误,因此它没有在下面我指示的条件下隐藏按钮FirebaseStorage.getInstance().getReference(); mImgCrediti = (ImageView)
findViewById
layout_constraintVertical_bias="1.0"
浏览 0
提问于2020-07-03
得票数 0
回答已采纳
2
回答
findViewById
(android.R.id.content)可以为Snackbar返回null吗?
android
、
findviewbyid
、
snackbar
无论如何,据推测这可以通过使用以下视图来完成:然而,我得到一个警告,这可能是空的,即使它似乎总是工作,无论我尝试它。
浏览 3
提问于2016-06-10
得票数 5
回答已采纳
1
回答
Android -
findViewById
(int id)总是返回空。
java
、
android
、
xml
、
listview
、
baseadapter
我创建了CreateEvent
活动
public void onClick(View v) { startActivity(in); });@Override public void friendsD
浏览 1
提问于2014-06-15
得票数 0
回答已采纳
1
回答
听者不要在我的
活动
中
开枪
android
、
onlongclicklistener
我试图
在
我的主要
活动
中
添加一个点击监听器和一个长点击监听器,但它没有触发。下面是我的代码,不知道它为什么不开火,有人能告诉我我错过了什么吗?是否可以将侦听器添加到整个
活动
中
?); RelativeLayout rl = (RelativeLayout)
findViewById
浏览 3
提问于2012-03-09
得票数 0
1
回答
访问xml layout android对象
android
、
android-layout
、
xml-layout
我有一个
活动
(MainActivity.java),其中的内容视图如下所示我的standalone_example.xmlandroid:layout_alignParentTop="true"</RelativeLayout> 我已经
在
PageCurlView.java
中<
浏览 2
提问于2012-06-24
得票数 0
回答已采纳
3
回答
在
活动
之外
调用
findViewById
返回null
android
将自定义视图附加到代码
中
的主视图中,然后,如果在
活动
类
中
调用
findViewById
,则可以找到添加的自定义视图,但它从普通java类
调用
findViewById
,则始终返回null。}}
在
调用
findViewById
内部ShyProgressBar时,非工作对象c值仍为空。如果使用下面的语句判断视图是否存在于
活动
类的load_data方法
中
,则可以工作
浏览 15
提问于2014-09-30
得票数 2
4
回答
如何处理片段
中
的onClick
java
、
android
、
xml
、
android-fragments
这是我对片段的第一次尝试,我无法处理android:onClick <Button android:layout_width="match_parent
FindViewById
()不能在片段
中
工作,我应该在哪里编写该方法?零碎的还是我的
活动
?
浏览 5
提问于2016-02-21
得票数 16
回答已采纳
2
回答
测试扩展
活动
实现onClickListener,
何时
/何处创建类" Test“的实例?
android
、
interface
、
instance
、
onclicklistener
在下面的代码
中
,类"Test“扩展了Acitivity并实现了OnClickListener。 playButton = (Button) this.
findViewById
浏览 0
提问于2013-10-13
得票数 1
回答已采纳
3
回答
ViewPager不从代码、android、eclipse更新
android
、
eclipse
、
listview
、
android-fragments
、
android-viewpager
首先,我
在
使用
findViewById
从片段
中
获取listView时遇到了问题,为了解决这个问题,我必须先膨胀片段的布局,然后使用“mContainer.
findViewById
.”。(R.id.lvdrawer); titleIndicator.setViewPager(pager);
浏览 6
提问于2015-04-15
得票数 0
回答已采纳
1
回答
在
已动态添加的布局
中
动态添加布局
java
、
android
、
xml
、
android-layout
、
layout
我正在处理一个android项目,我试图
在
另一个项目中动态地添加一个布局。问题是父布局也是动态添加的.其目的是能够使用布局模板(我可以多次膨胀),并在每个布局
中
添加另一个布局(也是从xml文件
中
膨胀的)。
在
主视图中,我添加的父布局如下所示:View layout= getLayoutInflater().inflate(R.layout.relative,
浏览 2
提问于2015-09-01
得票数 0
回答已采纳
3
回答
安卓系统
中
findViewById
()上的NullPointerException
java
、
android
、
android-activity
、
nullpointerexception
、
android-edittext
在下面的代码
中
,我使用
findViewById
()
在
第9/10行获得了一个NullPointerException。
在
我的主类
中
,我只是实例化了这个类
中
的一个对象,以使用.getFrom()EditText etFrom;EditText etTill; etFrom = (Ed
浏览 1
提问于2011-05-23
得票数 7
1
回答
公共静态变量有值,但当我试图将它显示给文本视图(
在
另一个类
中
)时,它没有值。
android
、
json
、
static-variables
我的
活动
流程,登录页->主页(在这里,我有一个按钮要转到Userprofile,其中有一个onclick方法)->按钮onclick方法是"startactivity(Userprofile)“,我有一个加载
活动
savedInstanceState); Toolbar toolbar = (Toolbar)
findViewById
= null; textView.setText
浏览 5
提问于2016-07-11
得票数 0
回答已采纳
点击加载更多
热门
标签
更多标签
云服务器
对象存储
ICP备案
云点播
腾讯会议
活动推荐
运营活动
广告
关闭
领券