Erreur java.lang.reflect.Method.invokeNative
Mon fichier java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
TextView T;
Button b1;
Button b2;
Context c = this;
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b2 = (Button) findViewById(R.id.b2);
T = (TextView) findViewById(R.id.T);
b1 = (Button) findViewById(R.id.b1);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Welcome to Our application", Toast.LENGTH_SHORT).show();
//Intent i = new Intent(MainActivity.this, authentification.class);
//startActivity(i);
}
})
;
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder alert = new AlertDialog.Builder(c);
alert.setTitle("Alert");
alert.setMessage("Voulez Vous Quitter");
alert.setPositiveButton("oui", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
alert.setNegativeButton("non", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alert.show();
}
});}
} |
Mon fichier Xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@mipmap/deux"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="welcome"
android:id="@+id/T"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:textColor="#ff0008"
android:textSize="80sp"
android:textStyle="bold|italic"
android:layout_alignParentStart="true"
android:allowUndo="false"
android:autoText="false"
android:clickable="false"
android:contextClickable="false"
android:drawableTint="#774545"
android:elegantTextHeight="false"
android:textIsSelectable="false"
android:textColorHint="#ffffff"
android:theme="@style/Base.Animation.AppCompat.DropDownUp"
android:visibility="visible" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b1"
android:width="120dp"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/T"
android:layout_marginLeft="-340dp"
android:layout_marginBottom="42dp"
android:visibility="invisible" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b2"
android:clickable="false"
android:width="100dp"
android:layout_marginRight="0dp"
android:layout_marginLeft="10dp"
android:layout_alignTop="@+id/b1"
android:layout_toStartOf="@+id/b1"
android:visibility="invisible" />
</RelativeLayout> |
le message d'erreur c'est java.lang.reflect.Method.invokeNative(Native Method)