Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 单击AlertDialog上的ImageView捕捉位置_Android_Imageview_Android Alertdialog - Fatal编程技术网

Android 单击AlertDialog上的ImageView捕捉位置

Android 单击AlertDialog上的ImageView捕捉位置,android,imageview,android-alertdialog,Android,Imageview,Android Alertdialog,我想为以下问题提供帮助:我有一个AlertDialog,它似乎包含一个sqlite列表,我使用了一个布局xml来加载这个列表,并且布局包含一个带有垃圾桶的ImageView。我创建了代码public void delete click View v{,其中会显示另一个AlertDialog,询问您是否确定排除。但是我无法获取单击的垃圾箱的位置 下面是一些代码片段: 公共空间视图v{ SQLiteDatabase db = openOrCreateDatabase("rmtc.db", C

我想为以下问题提供帮助:我有一个AlertDialog,它似乎包含一个sqlite列表,我使用了一个布局xml来加载这个列表,并且布局包含一个带有垃圾桶的ImageView。我创建了代码public void delete click View v{,其中会显示另一个AlertDialog,询问您是否确定排除。但是我无法获取单击的垃圾箱的位置

下面是一些代码片段:

公共空间视图v{

    SQLiteDatabase db = openOrCreateDatabase("rmtc.db", Context.MODE_PRIVATE, null);

    Cursor cursor = db.rawQuery("SELECT * FROM favpontos ORDER BY apelido ASC", null);

    String[] from = {"apelido", "ponto"};
    int[] to = {R.id.txvApelido, R.id.txvPonto};

    final SimpleCursorAdapter ad = new SimpleCursorAdapter(getBaseContext(), R.layout.favoritos, cursor, from, to);




    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle("Pontos favoritos");
    builder.setIcon(R.drawable.ic_logo_white);
    builder.setAdapter(ad, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
             // Do something with the selection


            int posicao = (int) ad.getItemId(id);

            SQLiteDatabase banco = openOrCreateDatabase("rmtc.db", Context.MODE_PRIVATE, null);
            Cursor c = banco.rawQuery("SELECT * FROM favpontos WHERE _id = "+ posicao, null);

            while(c.moveToNext()){

                EditText txtPonto = (EditText)findViewById(R.id.txtPonto);
                txtPonto.setText(c.getString(c.getColumnIndex("ponto")));

            }





        }

    });
    AlertDialog alert = builder.create();
    alert.show();




}

public void deleteClick(View v) {


    new AlertDialog.Builder(MainActivity.this)
    .setTitle("Deletar ponto favorito")
    .setMessage("Tem certeza que deseja deletar este ponto?")
    .setIcon(R.drawable.ic_logo_white)
    .setPositiveButton("Deletar", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int item) {
            // TODO Auto-generated method stub



            Toast.makeText(getBaseContext(), "( " +POSITION????+ " )", Toast.LENGTH_LONG).show();
        }


        })


    .setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub

        }


    })


    .show();    



} 
和xml布局:favoritos.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/ic_menu_delete"
        android:onClick="deleteClick" />

    <TextView
        android:id="@+id/txvApelido"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/imageView1"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/txvPonto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/txvApelido"
        android:layout_toLeftOf="@+id/imageView1"
        android:text="Small Text"
        android:textAppearance="?android:attr/textAppearanceSmall" />

</RelativeLayout>
谢谢

原谅英国人,我来自巴西