我的问题是,如何在点击android carousel查看图片时启动多项活动?
我试着编写下面给出的一些代码。但它只能一个一个地启动一个活动而不是一个活动,所以请仔细检查......
public class MyFragment extends Fragment {
public static Fragment newInstance(MainActivity context, int pos, float scale, boolean isBlured) {
Bundle b = new Bundle();
b.putInt("pos", pos);
b.putFloat("scale", scale);
return Fragment.instantiate(context, MyFragment.class.getName(), b);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/* if (container == null) {
return null;
}*/
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(400,400);
LinearLayout fragmentLL = (LinearLayout) inflater.inflate(R.layout.mf, container, false);
int pos = this.getArguments().getInt("pos");
TextView tv = (TextView) fragmentLL.findViewById(R.id.text);
tv.setText("Image " + pos);
ImageView iv = (ImageView) fragmentLL.findViewById(R.id.pagerImg);
iv.setLayoutParams(layoutParams);
iv.setImageResource(MainActivity.mainActivityCtx.coverUrl[pos]);
iv.setPadding(15, 15, 15, 15);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
/*Intent intent = new Intent(getActivity(),image1.class);
startActivity(intent);*/
int postion=0;
switch (postion)
{
case 0: Intent newActivity0 = new Intent(getActivity(), image1.class);
startActivity(newActivity0);
break;
case 1: Intent newActivity1 = new Intent(getActivity(), image2.class);
startActivity(newActivity1);
break;
case 2: Intent newActivity2 = new Intent(getActivity(), image3.class);
startActivity(newActivity2);
break;
case 3: Intent newActivity3 = new Intent(getActivity(), image4.class);
startActivity(newActivity3);
break;
case 4: Intent newActivity4 = new Intent(getActivity(), image5.class);
startActivity(newActivity4);
break;
}
}
});
// MyLinearLayout root = (MyLinearLayout) fragmentLL.findViewById(R.id.root);
//float scale = this.getArguments().getFloat("scale");
//root.setScaleBoth(scale);
return fragmentLL;
}
}
R.id.pagerImage是LinearLayout图像的id。
答案 0 :(得分:0)
在if (!pdata->empty()) {
os << pdata->front();
std::for_each(std::next(pdata->begin()), pdata->end(),
[&os](auto&& v){ os << ", " << v; });
}
final
int pos
将final int pos = this.getArguments().getInt("pos");
语句的变量switch
更改为position
pos