我想在android视图中创建这个iphone tableview功能吗?

时间:2014-04-10 07:04:57

标签: android listview

我希望在android中创建同样的iphone tableview功能如何做到这一点 有没有任何想法如何在Android列表视图中这样做我认为它是最接近listview如何没有更改listview项目显示删除按钮我把图像放在这里,所以你可以检查它

  

当我点击编辑按钮时显示删除按钮的每一行   列表视图

enter image description here

  

单击按钮列表视图后,如此图像更改

enter image description here

1 个答案:

答案 0 :(得分:1)

getView()源代码,用于在点击编辑时处理删除按钮的可见性。

@Override
        public View getView(final int position, View convertView, ViewGroup parent)
        {
            View row = convertView;
            TextView playerNameTextView, gameStatusTextView ;

            final NotiMyTurn notiItem = this.noti.get(position);

            if (row == null)
            {
                LayoutInflater inflater = ((Activity) context).getLayoutInflater();
                row = inflater.inflate(layoutResourceId, parent, false);
            }

            playerNameTextView = (TextView) row.findViewById(R.id.textview_my_turn_player_name);
            gameStatusTextView = (TextView) row.findViewById(R.id.textview_my_turn_game_status);
            img_game_play = (ImageView) row.findViewById(R.id.img_my_turn_play);
            img_player_delete = (ImageView) row.findViewById(R.id.img_player_delete_button);
            img_player_pic = (ImageView) row.findViewById(R.id.img_player_pic_my_turn);

            playerNameTextView.setText(notiItem.playerName);
            gameStatusTextView.setText(notiItem.gameStatus);

            if(editMode)
            {
                    //img_game_play.setVisibility(View.INVISIBLE);
                    img_player_delete.setVisibility(View.VISIBLE);
                    img_player_delete.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.fade_in));
                    img_player_pic.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move));
                    playerNameTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move));
                    gameStatusTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move));
                    img_game_play.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.fade_out));

            }
            else
            {
                if(isEditClickedFirst)
                {
                    img_game_play.setVisibility(View.VISIBLE);
                    img_player_delete.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.fade_out));
                    img_player_pic.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move_back));
                    playerNameTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move_back));
                    gameStatusTextView.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.move_back));
                    img_game_play.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.fade_in));

                }
                img_player_delete.setVisibility(View.GONE);
            }

            row.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick(View v)
                {
                    Toast.makeText(activity, "Clicked", Toast.LENGTH_SHORT).show();
                }
            });

            return row;
        }