0

ListViewの位置2にあるボタンをクリックするなどのシナリオを自動化したい。PFBコードは、ListViewのインデックス1にあるボタンを自動的にクリックします

TextView a = (TextView)solo.getView(R.id.dialog);
solo.clickOnView(a);
4

2 に答える 2

0

Why don't you use performClick() method on the ListViews item like that:

   ((Button)((View) listView.get(1)).findViewById(R.id.mybutton)).performClick();

if you want just make itemClick, you should use onItemCkick() of the ListView

于 2012-10-19T05:40:41.247 に答える
0

そのボタンには特定の ID があります。setTag()そのボタンのタグを設定してから、on click event:: like を設定します

 getView((int position, View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
          LayoutInflater inflater = context.getLayoutInflater();
             // use inflater and do all those normal things..
    }
   view.setTag(position);
   myButton.setTag(view.getTag());          
   myButton.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
           Toast.makeText(getContext()," Slot Button clicked " +  v.getTag(),Toast.LENGTH_SHORT).show();
        }
    });
于 2012-10-19T05:37:46.183 に答える