2

我需要创建ListView类似Samsung Contact List. 我需要显示该行的自定义布局,而该行是swiped. 并且还需要在该行的背景显示联系方式。请给我一些想法或参考。

谢谢你。

list.setOnItemClickListener(stationSelectionListener);
final ListSwipeDetector listSwipeDetector=new ListSwipeDetector();
list.setOnTouchListener(listSwipeDetector);
new UserAndMessageCount(StationListActivity.this).execute();
list.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (listSwipeDetector.swipeDetected()){
                    Toast.makeText(StationListActivity.this,"sWIPE1",Toast.LENGTH_LONG).show();
                    LayoutInflater inflater=(LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View viewNew=inflater.inflate(R.layout.view_flow_common_page, null);
                    view=viewNew;
                } 
                else {
                    ConstantValues.STATION_NAME=((TextView)view.findViewById(R.id.textView)).getText().toString();
                    LayoutInflater inflater=(LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    View viewNew=inflater.inflate(R.layout.view_flow_common_page, null);
                    //startActivity(new Intent(getApplicationContext(), StationSelectionActivity.class));
                }
            }
    });
    list.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view,int position, long id) {
            if (listSwipeDetector.swipeDetected()){
                Toast.makeText(StationListActivity.this,"sWIPE3",Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(StationListActivity.this,"sWIPE4",Toast.LENGTH_LONG).show();
            }
            return false;
        }
    });
4

1 回答 1

2

之内onItemClickListener,可以实施onItemClick (AdapterView<?> parent, View view, int position, long id)。如果您检索view,则可以在用户单击该项目时对其进行所需的更改。

对于刷卡,您可以修改适配器的getItem()功能并添加一个GestureListener或类似此代码的内容。然后,您可以收听滑动并采取相应措施。

于 2013-02-07T08:10:24.767 回答