标题基本上说明了这个问题。我提到了这个问题:https://english.stackexchange.com/questions/11481解决了后一个问题,但后来却给了我前一个问题。
public class PbfSampleApplication extends Application {
public static final String TAG = "PbfSampleApplication";
@Override
public void onCreate() {
super.onCreate();
startService(new Intent(this.getApplicationContext(),
PbfSampleService.class));
FlicManager.init(this.getApplicationContext(), "2125f7c3-0d0e-42d5-88fe-
fda8765867d6", "94d6448c-22d3-4d2e-951f-f625f60f471a");
FlicManager manager = FlicManager.getManager();
for (FlicButton button : manager.getKnownButtons()) {
button.connect();
listenToButtonWithToast(button);
}
}
public void listenToButtonWithToast(FlicButton button) {
button.addEventListener(new FlicButtonAdapter() {
@Override
public void onButtonUpOrDown(FlicButton button, boolean wasQueued, int timeDiff, boolean isUp, boolean isDown) {
if (isDown) {
View v =LayoutInflater.inflate(R.layout.activity_main);
//Above line has the error
View innerView = v.findViewById(R.id.number);
Toast.makeText(getApplicationContext(), "Button " + button + " was pressed", Toast.LENGTH_SHORT).show();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:017702329065"));
startActivity(callIntent);
}
}
});
}
}
我知道我应该传入一个int但是当我在开发者网站上检查方法时,看起来参数格式正确,所以我不知道还需要我还需要什么工作
答案 0 :(得分:0)
在调用之前创建一个LayoutInflater实例:
<span>text</span>
第二个参数是LayoutInflater inflater = LayoutInflater.from(getContext());
View v = inflater.inflate(R.layout.activity_main, null);
View innerView = v.findViewById(R.id.number);
,可以为null。 ViewGroup
没有只带一个参数的inflate方法