I have a layout with a TextView labelled as Camera. On the click of that TextView I have to show camera. The layout is set to a dialog. The following is the code i have done
public class SelectCameraOrGalleryAlertDialog extends Dialog {
public SelectCameraOrGalleryAlertDialog(Context context) {
super(context);
}
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.alerttoselectcameraorgallery);
final View txtCamerabutton = (View) findViewById(R.id.txtcamerabutton);
txtCamerabutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivity(intent);
}
});
}
}
Here error shows as The method startActivity(Intent) is undefined for the type new View.OnClickListener(){}
This is the layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="70dp"
android:gravity="center"
android:background="#e29567">
<TextView
android:layout_width="126dp"
android:layout_height="fill_parent"
android:drawableLeft="@drawable/addressicon"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:text="Add Photo"
android:textSize="19sp"
android:textColor="#3a3a3a"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="90dp"
android:layout_gravity="center"
android:orientation="horizontal"
android:background="#3a3a3a" >
<TextView
android:id="@+id/txtcamerabutton"
android:layout_width="94dp"
android:layout_height="fill_parent"
android:paddingTop="5dp"
android:drawableTop="@drawable/editicon"
android:gravity="center"
android:scaleX=".5"
android:scaleY=".5"
android:text="Camera" />
<TextView
android:id="@+id/txtgallerybutton"
android:layout_width="94dp"
android:layout_height="fill_parent"
android:paddingTop="5dp"
android:drawableTop="@drawable/replaceicon"
android:gravity="center"
android:scaleX=".5"
android:scaleY=".5"
android:text="Gallery" />
</LinearLayout>
</LinearLayout>
How to solve this?