简体   繁体   English

如何在android的主要活动中声明另一个活动的按钮?

[英]How to declare a button from another activity in the main one in android?

I have a problem with accessing a button from another activity.我在访问另一个活动的按钮时遇到问题。 I was searching all over the internet and the best I found is this:我在互联网上搜索,我找到的最好的是:

View inflatedView=getLayoutInflater().inflate(R.layout.activity_songcontrol, null);
final Button playNpauseBtn = (Button)inflatedView.findViewById(R.id.pauseNplayBtn);`

When I click the button nothing happens and I get mSecurityInputMethodService is null in logcat当我单击按钮时,没有任何反应,我在 logcat 中得到mSecurityInputMethodService is null

this approach is not recommended.不推荐这种方法。 It's best to have a layout that can include another layout to reuse the same button最好有一个可以包含另一个布局的布局来重用相同的按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android的另一个活动中调用按钮? - How to call a button from another activity in Android? 如何从Android中的片段访问主要活动按钮 - how to access main activity button from fragment in android 如何从一个活动转移到活动之外的另一个活动 - how to move from an activity to another one from outside an activity android 如何在Android中将哈希映射数组从一个活动发送到另一个活动 - How to send array of Hashmap from one activity to another activity in android 如何将多个记录从一个活动传递到android中的另一个活动? - How to pass multiple records from one activity to another activity in android? 如何在Android中将两个字符串从一个活动传递到另一个活动 - How to pass two Strings from one Activity to another Activity in Android 问:Android-如何在不单击按钮的情况下从另一个活动开始 - Q: Android - How to start one activity from another without button click 如何使用按钮将主要活动连接到另一个活动? - How can I connect the main activity to another activity using a button? 如何使用按钮从一个活动移动到另一个活动? - How to move from one Activity to another using a button? 如何将按钮单击时的 int 值从一个活动传递到另一个活动? - How to pass int value on button click from one activity to another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM