简体   繁体   English

对话框内容不会根据该行更改

[英]Dialog box content doesnot change according to that row

I am giving one button in all the row,if we click that button dialog box has to appear in that one it has to display the content according to the row. 我在所有行中都提供了一个按钮,如果单击该按钮对话框必须出现在其中,则该对话框必须根据该行显示内容。

public void bindView(View view, Context context, final Cursor cursor){
                int row_id = cursor.getColumnIndex("_id");  //Your row id (might need to replace)
                TextView tv = (TextView) view.findViewById(R.id.text2);
                final TextView tv1 = (TextView) view.findViewById(R.id.text1);
                TextView tv2 = (TextView) view.findViewById(R.id.date);
                CheckBox cb = (CheckBox) view.findViewById(R.id.checkbox);
                int col1 = cursor.getColumnIndex("expname");
                final String expname = cursor.getString(col1 );
                int col2 = cursor.getColumnIndex("expcontent");
                final String expcontent = cursor.getString(col2 );
                int col3 = cursor.getColumnIndex("expdate");
                final String expdate = cursor.getString(col3);
                cb.setTag(cursor.getPosition());
                cb.setChecked(mCheckStates.get(cursor.getPosition(), false));
                cb.setOnCheckedChangeListener(this);
              //  TextView tv2 = (TextView) view.findViewById(R.id.text3);
                //cursor.getColumnName(1)
                tv.setText( expname);
                tv1.setText( expcontent);
               tv2.setText(expdate);
                //tv2.setText( ""+cursor.getColumnIndex(GinfyDbAdapter.CATEGORY_COLUMN_COUNT));
             //   String[] from = new String[]{GinfyDbAdapter.CATEGORY_COLUMN_TITLE, GinfyDbAdapter.CATEGORY_COLUMN_CONTENT, GinfyDbAdapter.CATEGORY_COLUMN_COUNT}
                ImageButton button = (ImageButton) view.findViewById(R.id.sms);
                button.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View v){
                        StringBuffer sb2 = new StringBuffer();
                    sb2.append("Title:");
                        sb2.append(Html.fromHtml(expname));
                        sb2.append(",Content:");
                        sb2.append(Html.fromHtml(expcontent));
                        sb2.append("\n");
                        String strContactList1 = (sb2.toString().trim());
                        sendsmsdata(strContactList1);
                    }
                });

                ImageButton button1 = (ImageButton) view.findViewById(R.id.mail);
                button1.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View v){
                        StringBuffer sb3 = new StringBuffer();
                    sb3.append("Title:");
                        sb3.append(Html.fromHtml(expname));
                        sb3.append(",Content:");
                        sb3.append(Html.fromHtml(expcontent));
                        sb3.append("\n");
                        String strContactList2 = (sb3.toString().trim());
                        sendmaildata(strContactList2);
                    }
                });

                ImageButton button2 = (ImageButton) view.findViewById(R.id.btnaudioprayer);
                button2.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View v){
                        //ADD STUFF HERE you know which row is clicked. and which button
                        typed = expcontent;
                        speakOut();
                    }
                });


                ImageButton button3 = (ImageButton) view.findViewById(R.id.bBlame);
                button3.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View v){
                        //ADD STUFF HERE you know which row is clicked. and which button
                        dialog.show();

                    }
                });

                dialog=new Dialog(ExperiencesActivity.this);
                dialog.setContentView(R.layout.exp1);
                dialog.setCancelable(true);
                dialog.setTitle("My Experiences");

                textview1 = (TextView)dialog.findViewById(R.id.tv11);



                textview1.setText("Title:" + expname);
                textview2 = (TextView)dialog.findViewById(R.id.tv22);
                textview2.setText("Content:" + expcontent);
                Button button23=(Button)dialog.findViewById(R.id.btnSubmit);
                button23.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        dialog.dismiss();

                    }
                });

But here my problem is it will not take the respective content in dialog box,whenever we click the first item in an button,it will shows the content in all the row of button click. 但是这里我的问题是它不会占用对话框中的相应内容,每当我们单击按钮中的第一项时,它将在按钮单击的所有行中显示内容。 Dialog box content has to change according to the row. 对话框内容必须根据行进行更改。

You need to create saperate classe for your textviews. 您需要为您的textview创建简单的类。 Like 喜欢

   private class ViewHolder {
            TextView textview1;
            TextView textview2;
             Button button23;
        }

Update your dialog like... 更新对话框,如...

public void showMyDialog(){

dialog=new Dialog(ExperiencesActivity.this);
ViewHolder viewholder;
                dialog.setContentView(R.layout.exp1);
                dialog.setCancelable(true);
                dialog.setTitle("My Experiences");

                ViewHolder.textview1 = (TextView)dialog.findViewById(R.id.tv11);
                ViewHolder.textview1.setText("Title:" + expname);
                ViewHolder.textview2 = (TextView)dialog.findViewById(R.id.tv22);
                ViewHolder.textview2.setText("Content:" + expcontent);
                ViewHolder.button23=(Button)dialog.findViewById(R.id.btnSubmit);
               ViewHolder.button23.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        dialog.dismiss();

                    }
                });
 dialog.show();
}

And call showMyDialog() method onclick of button. 并在按钮的onclick上调用showMyDialog()方法。

 ImageButton button3 = (ImageButton) view.findViewById(R.id.bBlame);
                button3.setOnClickListener(new OnClickListener(){
                    @Override
                    public void onClick(View v){
                        //ADD STUFF HERE you know which row is clicked. and which button
                        showMyDialog();

                    }
                });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java表CustomTableCellRenderer根据单元格内容值更改行颜色 - java table CustomTableCellRenderer change row color according to cell content value 以编程方式更改对话框中的复选框状态? - Programatically change check box state in dialog box? 从WindowsBuilder中的另一个对话框更改一个对话框中的信息? - Change information in a dialog box from another dialog box in WindowsBuilder? 如何根据json数组长度在对话框中添加动态复选框? - How to add dynamic checkbox in dialog box according to json array length? 在Java的模式对话框中显示div内容 - Display div content in a modal dialog box in java 如何根据单击的项目更改listview的内容? - how to change the content of listview according to the clicked item? 更改HTML对话框的样式(CSS) - Change style (CSS) of HTML dialog box Android对话框,更改小部件可见性 - Android Dialog box, change widget visibility 是否可以根据Applet中的语言更改消息对话框中的“确定”? - Is there any way to change the “ok” in message dialog according to the language in Applet? 如何更改打开对话框的图像以及如何自定义对话框? - How change the image of open Dialog box and how to customize Dialog box in swing?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM