我需要在水平旋转木马中突出显示一个项目,当用户在水平旋转木马中选择另一个项目时,我想要突出显示该项目(删除较早的项目并突出显示当前所选项目)。为此,我正在使用活动页面中的代码。
public void setemploye(){
final DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
final int imageWidth = (int) (displayMetrics.widthPixels / INITIAL_ITEMS_COUNT);
Log.i("imagewidthhhh", String.valueOf(imageWidth));
imageItem = new ImageView(this);
imageItem.setLayoutParams(new LinearLayout.LayoutParams(150, 150));
Log.i("genderrrrrrr",gender);
if(gender.equals("MALE")){
// Set the image view resource
imageItem.setBackgroundResource(R.mipmap.avatar);
}
else{
imageItem.setBackgroundResource(R.mipmap.woman);
}
Log.i("teammemmm iddcarod",team_member_id);
mCarouselContainer.addView(imageItem);
imageItem.setOnClickListener(new View.OnClickListener() {
@Override
// On click function
public void onClick(View view) {
TextView tvname = (TextView) findViewById(R.id.emp_name);
tvname.setText("Selected Employee: " + firstname);
//
//socialMedia();
Log.i("String firstname", String.valueOf(tvname));
gettimeslots();
}
});
}
这是xml中的代码
<HorizontalScrollView
android:id="@+id/horizontalscroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:layout_below="@+id/employee"
android:layout_centerHorizontal="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:fillViewport="false">
<!-- Carousel items container - lays out items horizontally -->
<LinearLayout android:id="@+id/carousel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>