我有两个阵列:
在输出上我需要一个数组数组,其数组中包含String
或int
。
像这样:
[
[string, int],
[string, int],
[string, int],
]
答案 0 :(得分:0)
您可以使用LINQ's Zip
执行此操作。
public class HomePage extends AppCompatActivity {
private GestureDetectorCompat gestureDetectorCompat;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_page);
gestureDetectorCompat = new GestureDetectorCompat(this, new MyGestureListener());
}
@Override
public boolean onTouchEvent (MotionEvent event) {
this.gestureDetectorCompat.onTouchEvent(event);
return super.onTouchEvent(event);
}
class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
//handle 'swipe up' action only
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2,
float velocityX, float velocityY){
/*
Toast.makeText (getBaseContext(),
event1.toString() + "\n\n" +event2.toSting(),
Toast.LENGTH_SHORT).show();
*/
if (event2.getX() < event1.getX()){
Toast.makeText(getBaseContext(),
"Swipe Up - startActivity()",
Toast.LENGTH_SHORT).show();
//switch another activity
Intent intent = new Intent(
HomePage.this, New_Page.class);
startActivity(intent);
}
return true;
}
}
}
结果
var strings = new[] { "a", "b", "c" };
var ints = new[] { 1, 2, 3 };
var result = strings.Zip(ints, (s, i) => new object[] { s, i });
Console.WriteLine(string.Join(", ", result.Select(x => "{ " + string.Join(", ", x) + " }")));