2012-10-26 44 views
1

我有一个Android的埃克莱尔(2.1)的电话,我正在经历呼叫记录功能和两个列表视图中点击项目

我通过一个ListView排在其上的触摸左侧我重定向到更详细的通话记录并在右侧另一个ListView中,我得到一个“呼叫”按钮,经过研究并通过我无法知道如何做到这一点在互联网上多个职位会

,我想实现这个功能在我的应用程序中的离子。

任何人都可以在这里请重定向我的任何好的教程是整洁。

回答

3

你可以做到这一点在getview方法在基础适配器:

public View getView(final int position, View convertView, ViewGroup parent) { 
    DemoClass holder; 
    if (convertView == null) { 
     convertView = mInflater.inflate(
       R.layout.layout_name, null); 
     holder = new DemoClass(); 
     holder.mTxtVwNameTag = (TextView) convertView 
       .findViewById(R.id.TxtVwOptionName); 

     holder.mBtnApply = (Button) convertView.findViewById(R.id.BtnApply);// Here you can handle onclick events for list view items 

     holder.mBtnApply.setFocusable(false); 

     holder.mBtnApply.setOnClickListener(new OnClickListener() { 
      public void onClick(View v) { 
       mIntPos = position; 
       Log.d("++++++++" , "List item Position : " + mIntPos); 
       new ApplyOfferAsync().execute(); 
      } 
     }); 

     convertView.setTag(holder); 
    } else { 
     holder = (DemoClass) convertView.getTag(); 
    } 
    try { 
     holder.mTxtVwNameTag.setText(mNameTags.get(position)); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    return convertView; 
} 
+0

你能把我重定向到一个完整的教程吗? –

+0

http://stackoverflow.com/questions/1709166/android-listview-elements-with-multiple-clickable-buttons – AppMobiGurmeet

+1

@HereticMonk这里是完整的教程:http://wiresareobsolete.com/wordpress/2011/08/clickable -Zones-in-listview-items/ – AppMobiGurmeet

1

,你必须使用的视图触摸听众或你coustom布局。

wv.setOnTouchListener(new OnTouchListener() 
    { 

     public boolean onTouch(View arg0, MotionEvent arg1) 
     { 
      try 
      { 
      if(arg1.getAction()==MotionEvent.ACTION_DOWN) 
      { 
       x_down = (int) arg1.getX(); 
       y_down = (int) arg1.getY(); 

      Log.v("log", "x pos is "+x_down +"y pos is "+y_down); 
      return true; 
      } 

      else if(arg1.getAction()==MotionEvent.ACTION_UP) 
      { 
       x_up = (int) arg1.getX(); 
       y_up = (int) arg1.getY(); 

      Log.v("log", "x pos is "+x_up +"y pos is "+y_up); 


      if((x_down-x_up)>30) 
      { 
       //do stuf here 
      } 
      else if((x_up-x_down)>30) 
      { 
       //do stuf here 
      } 
      return false; 
      } 
      else 
      { 
       return false; 
      } 

      } 


      catch (Exception e) 
      { 
       e.printStackTrace(); 
       return false; 

      } 


     } 
    }); 
相关问题