1

I want to add a Button in the title Bar .I have followed this tutorial . How to add Button For this reason I have the following class :

public class CustomWindow extends Activity {
    protected TextView title;
    protected ImageView icon; 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);       
    //Request for custom title bar
    this.requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);   
        //set to your layout file
        setContentView(R.layout.activity_amtob);        
        //Set the titlebar layout
        this.getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title); 
    }   

    public void linkedinBtnClicked(View v)
    {
           //Implement the button click event 
        //Toast.makeText(this, "Button is clicked", Toast.LENGTH_LONG).show();


       }
}

In title.xml I have the following code :

<RelativeLayout xmlns:android=
          "http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="40dp"
    android:orientation="horizontal" android:paddingLeft="5dp"
    >

    <TextView android:id="@+id/title" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text="Subscriber Verification"
         />

    <ImageButton android:src="@drawable/logout"
         android:layout_width="28dp"
        android:layout_height="28dp" android:clickable="true"
        android:layout_alignParentRight="true" 
        android:id="@+id/linkedinBtn"
        android:onClick="linkedinBtnClicked" />
</RelativeLayout>

But when I have extends the CustomWindow as follows I got exception and activity closes .

public class AMTOB_activity extends CustomWindow implements View.OnClickListener {

    String fingerPrintDataFileName = null;
    Button grabFingerData, sendRequest, photoUploader;

    public String photoBytes = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_amtob);

        grabFingerData = (Button) findViewById(R.id.grabDataButtonId);
        grabFingerData.setOnClickListener(this);

        sendRequest = (Button) findViewById(R.id.sendReq);
        sendRequest.setOnClickListener(this);
        // sendRequest.setVisibility(View.GONE);

    }
}

Why This exception occurs ? How can I solve this exception ? How can I see what exception has occurred ?

osimer pothe
  • 2,827
  • 14
  • 54
  • 92

0 Answers0