我在布局中引用了一个android小部件,但是该应用程序无法运行。我该如何解决?
package com.phrixian.phrixianprojects.phrixianprojectsserver;
import android.content.Intent;
import android.graphics.Typeface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button btnSignIn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent signIn = new Intent(MainActivity.this, SignIn.class);
startActivity(signIn);
}
});
}
}
这是我的activity_main.xml文件:
<LinearLayout
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<info.hoang8f.widget.FButton
android:id="@+id/btnSignIn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:text="Sign In"
android:textColor="@android:color/white"
app:cornerRadius="4dp"
app:fButtonColor="#00A9D440"
app:shadowColor="#00000000"
app:shadowEnabled="true"
app:shadowHeight="5dp" />
</LinearLayout>
输出内容如下:“由以下原因引起:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'void android.widget.Button.setOnClickListener(android.view.View $ OnClickListener)'” >