[英]calling an activity and/or service from launcher
im having problem calling a new activity or service using a button from this java file and how can i make the button just a picture without background and i always get this one "No activity specified! Getting the launcher activity." 即时通讯在使用此java文件中的按钮调用新活动或服务时遇到问题,我如何才能使按钮只是一张没有背景的图片,而我总是收到此“未指定活动!正在启动启动器活动”。 new programmer here sorry thank you
新程序员在这里对不起谢谢
package com.bpi.gears;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
public class DashboardListing extends Activity {
public static ImageButton bot4;
public static Intent activity_profile;
@SuppressWarnings("unused")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard_listing);
bot4 = (ImageButton)findViewById(R.id.bot4);
Intent activity_profileintent = new
Intent(DashboardListing.this,activity_profile.class);
bot4.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(activity_profile);
}});
}
}
to this one 到这个
package com.bpi.gears;
import android.os.Bundle;
import android.app.Activity;
public class activity_profile extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
}
}
In your startActivity() you should be passing "activity_profileintent" instead of activity_profile. 在您的startActivity()中,您应该传递“ activity_profileintent”而不是“ activity_profile”。 Something like this:
像这样:
startActivity(activity_profileintent);
Try this rather than the way you're doing it 试试这个,而不是做事的方式
Intent intent = new Intent();
intent.setClass(CurrentActivity.this, DestinationActivity.class);
startActivity(intent);
Remove @SuppressWarnings("unused") from your activity. 从您的活动中删除@SuppressWarnings(“ unused”)。 And register your destination activity into manifest.
并将您的目标活动注册到清单中。 Do not use static variables for intent.
不要将静态变量用于意图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.