mobile.jpg

위의 그림처럼 리스트 안에 버튼을 넣으려고 custom adapter를 사용하여 구현 하였습니다.

목록을 클릭하면 새로운 activity를 불러오고

버튼을 클릭하면 또다른 activiy를 불러오려 합니다.

문제는 버튼을 넣으니 목록 클릭이벤트가 발생을 하지 않습니다.

도와 주세요.


@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ArrayList<Content> m_orders = new ArrayList<Content>();
       
        //목록 데이터 로드
        HttpList httpList = new HttpList("http://edms.nomadconnection.com:8080/demo/ch-android.php");
        strURIs=httpList.getURI();
        strTitles=httpList.getTitle();
       
        for(int i=0;i<strTitles.length;i++){
         Content c = new Content(strTitles[i], strURIs[i]);
         m_orders.add(c);
        }
       
      
       
        ContentAdapter m_adapter = new ContentAdapter(this, R.layout.row, m_orders);
        setListAdapter(m_adapter);      
               
    }

    @Override
    protected void onListItemClick(android.widget.ListView l, View v, int position, long id) {
     Intent intent = new Intent(Main.this, VideoPlayer.class);
  Log.d("MyTag",strURIs[position]);
  intent.putExtra("filepath", strURIs[position]);
  startActivityForResult(intent, 1);
    }
   
    private class ContentAdapter extends ArrayAdapter<Content> {

        private ArrayList<Content> items;

        public ContentAdapter(Context context, int textViewResourceId, ArrayList<Content> items) {
                super(context, textViewResourceId, items);
                this.items = items;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.row, null);
                }
                Content p = items.get(position);
                if (p != null) {
                        TextView tt = (TextView) v.findViewById(R.id.toptext);
                        if (tt != null){
                         tt.setText(p.getTitle());                           
                        }

                }
                return v;
        }
    }