3

我添加了引线广告(入口广告)。广告正常工作,但当我从关闭标志关闭广告时,listview.click 不起作用。(Listview.click 不做任何事情,当我删除 AdController 时它可以工作)

public class SoundList extends ListActivity {

int [] soundfile;
MediaPlayer mediaPlayer;
private AdController myController;
final Activity act = this;


@Override
public void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);


    myController = new AdController(act, "111111111");
    myController.loadAd();
    soundfile= new int[] {R.raw.sound1,R.raw.sound2.....};

    String[] sounds= getResources().getStringArray(R.array.sounds);        
    // Binding Array to ListAdapter
    this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, sounds));
    ListView lv = getListView();

    lv.setDescendantFocusability(ListView.FOCUS_BLOCK_DESCENDANTS);
    // listening to single list item on click
    lv.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent, View view,
          int position, long id) {     

          Intent intent = new Intent(getApplicationContext(), SingleListItem.class);
          intent.putExtra("position", position);
          startActivity(intent);      

      }
    });
}
4

1 回答 1

3

在 ListView 的一行中有一个可聚焦的项目会导致OnItemClickListener不被调用。

要解决此问题,请将以下代码添加到行视图。

XML:

android:descendantFocusability="blocksDescendants"

爪哇:

listItem.setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);
于 2013-05-08T20:58:50.113 回答