0
私はこのプロジェクトApp demo videoを持っています。水平方向のスクロールビューに6種類の画像を追加する必要があり、それぞれにダイアログの断片があります。 水平スクロールビューで画像の位置を見つけたり、スライドしたときにビューを削除するにはどうすればよいですか?スライド式ジェスチャーを使用して水平スクロールビューでアイテムを削除するにはどうすればよいですか?
final String[] AddCustomitems = {"Blink single message", "Blink double message", "Message", "Scroll", "Split", "Temp"}; //list of items that can be added in layout
int[] customviewsDrawable = new int[]{R.drawable.custom_blink, R.drawable.custom_blink_double, R.drawable.custom_message, R.drawable.custom_scroll, R.drawable.custom_split_double, R.drawable.temp};
public void CustomAnimationList(final Activity activity) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
//set the title for alert dialog
builder.setTitle("Dot Matrix Add view");
//set items to alert dialog. i.e. our array , which will be shown as list view in alert dialog
builder.setItems(AddCustomitems, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
// setting the button text to the selected item from the list
AddItem(item);
}
});
//Creating CANCEL button in alert dialog, to dismiss the dialog box when nothing is selected
builder.setCancelable(false)
.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//When clicked on CANCEL button the dalog will be dismissed
dialog.dismiss();
}
});
// Creating alert dialog
AlertDialog alert = builder.create();
//Showing alert dialog
alert.show();
}
void AddItem(final int itemNum) {
if (countItem < 9) {
final float scale = getResources().getDisplayMetrics().density;
int dpWidthInPx = (int) (175 * scale); //rescalling views
int dpHeightInPx = (int) (250 * scale); //rescalling views
final LinearLayout sv = (LinearLayout) findViewById(R.id.horizontalLayout);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(dpWidthInPx, dpHeightInPx);
layoutParams.setMargins(10, 0, 0, 10); //adding margin
final ImageView iv = new ImageView(this);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertView(itemNum); //this will send itemNum to switch case for corresponding dialog fragment.
}
});
iv.setLayoutParams(layoutParams);
iv.setBackgroundResource(customviewsDrawable[itemNum]);
sv.addView(iv);
countItem++;
} else {
alertItem(); //alert message if items are more then 8
}
System.out.println("count items :" + countItem);
}
はあなた 'GestureDetector' – pskink
はまだ実装されていないとのコードを投稿してください。私は私が追加しているビューの位置を得ることができません。ビューの位置を表示する方法は? –
'View#getTop'(左/右/下) – pskink