2016-04-06 26 views
1

私はちょうどアンドロイドのための開発を学び始めました。私は質問があります。私はそれが可能かどうかは分かりませんが、まあ、私はちょうどそれを尋ねるつもりです。関連トピックを検索しましたが、多く見つけましたが、徐々にまたはスムーズに行を削除/削除するのに役立つトピックはありません。アニメやそのようなもののように削除したいと思っています。このコードでは、それだけで消えると多分あなたは、あなたがボタンを押した気付いていない:リストビューから削除行のアニメーション

Button removeButton = (Button) row.findViewById(R.id.listbutton); 
    removeButton.setTag(position); 
    removeButton.setOnClickListener(new Button.OnClickListener() { 
       @Override 
       public void onClick(View v) { 
        Integer index = (Integer) v.getTag(); 
        elements.remove(index.intValue()); 
        notifyDataSetChanged(); 
       } 
      } 
    ); 

私はここに私の2つのXMLコードを追加して、リストのレイアウトと列レイアウトが結果に影響を与える場合、私は知りません:

一覧レイアウト

<ListView 
     android:id="@+id/list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    </ListView> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_above="@id/list" 
    /> 
</RelativeLayout> 

行レイアウト

<ImageView 
    android:layout_width="50dp" 
    android:layout_height="50dp" 
    android:id="@+id/img" 
    android:src="@mipmap/ic_launcher" 
    android:layout_marginRight="10dp" 
    /> 

<TextView 
    android:id="@+id/nom" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@id/img" 
    android:textSize="20sp" 
    android:text="Nom Persona" 

    /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/edat" 
    android:layout_toRightOf="@id/img" 
    android:layout_below="@id/nom" 
    android:textSize="15sp" 
    android:text="Edat" 
    /> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:tag="buttontag" 
    android:id="@+id/listbutton" 
    android:layout_alignParentRight="true" 
    android:drawableLeft="@mipmap/eliminar" 
    android:text="@string/eliminar" 
    android:layout_marginTop="-10dp" 
    /> 

ご覧のとおり、編集可能なテキストを下に追加していますが、その中には払わないでください。

ありがとうございました!

答えて

0

プレミードアニメーションを使用したい場合は、ほとんどの場合、カスタマイズすることはほとんどできませんが、そのジョブを実行するライブラリを使用することができます。私はあなたが復元するものを実装することができる場合は、削除アニメーションは、ライブラリでかなりいいと思います... githubでアニメーションを探し、その実装方法を参照してください: ListViewAnimations Library Github

関連する問題