i have custom alert dialog with two button inside. but each button have error null object reference, i want to make my relativelayout clickable and here is my java code :
RelativeLayout relaCamera;
RelativeLayout relaGallery;
relaCamera = findViewById(R.id.relaCameraIntent);
relaGallery = findViewById(R.id.relaGalleryIntent);
......
......
private void pickFromGallery() {
LayoutInflater layoutInflater = LayoutInflater.from(this);
View view = layoutInflater.inflate(R.layout.upload_video_options, null);
final AlertDialog alertD = new AlertDialog.Builder(this).create();
relaCamera.setOnClickListener(new View.OnClickListener() { // error here
public void onClick(View v) {
Intent intent = new Intent();
intent.setTypeAndNormalize("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(Intent.createChooser(intent, "Select Video"), REQUEST_GET_VIDEO);
}
});
relaGallery.setOnClickListener(new View.OnClickListener() {// error here
public void onClick(View v) {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
}
}
});
alertD.setView(view);
alertD.show();
}
here is my upload_video_options.xml for customize the alert dialog:
<RelativeLayout
android:id="@+id/relaCameraIntent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:clickable="true"
android:gravity="center_horizontal"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:id="@+id/relaGalleryIntent"
android:clickable="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">