我想打电话给这个方法
public void openButton(View view) {
Intent intent = new Intent(this, MainActivity.class);
this.startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
从像这样的简单方法
public void simple(){
openButton();
}
Run Code Online (Sandbox Code Playgroud)
但我不能这样做,因为openButton需要一个参数View.怎么样?
我有两个按钮:
<button onclick=initialize() id="1" data-role="button" data-mini="true" data-corners="false" data-theme="b">Show My Position</button>
<button onclick=calcRoute() id="2" data-role="button" data-mini="true" data-corners="false" data-theme="b">Evacuate !</button>
Run Code Online (Sandbox Code Playgroud)
我希望默认情况下禁用第二个按钮,并在单击第一个按钮时启用它.我该如何做到这一点?
我必须从这个类中访问变量ammoMagazine
public class Pistol : MonoBehaviour {
public int ammoMagazine = 7;
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试了这段代码:
public class AmmoCounter : MonoBehaviour {
public int ammo;
private Pistol _pistol;
void Start () {
_pistol = GetComponentInChildren<Pistol>();
}
void Update () {
ammo = _pistol.ammoMagazine;
guiText.text = "Pistol: " + ammo + "/7";
}
}
Run Code Online (Sandbox Code Playgroud)
为什么有NullReferenceException:对象引用未设置为对象的实例?谢谢,我是新的C#
我想从“ http://usa8-vn.mixstream.net:8138 ”流式传输时获取歌曲名称和名称。流是有效的,但我不知道为什么当我想用 MediaMetaDataReceiver 获取歌曲标题时,它总是说 IllegalArgumentException。我已经在使用此代码/sf/answers/768132711/但不知何故它对我不起作用。
MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever();
metaRetreiver.setDataSource("http://usa8-vn.mixstream.net:8138");
String artist = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
String title = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
Run Code Online (Sandbox Code Playgroud)
第 2 行总是出错,并说 IllegalArgumentException,但是当我使用 MediaPlayer 的链接时,它的工作方式是这样的
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource("http://usa8-vn.mixstream.net:8138");
Run Code Online (Sandbox Code Playgroud)
请帮帮我,谢谢。