введите описание изображения здесь
Пожалуйста, обратитесь к изображению выше
public class complaintAdapter extends
RecyclerView.Adapter<RecyclerView.ViewHolder> {
private Context context;
String hello, status, type;
private LayoutInflater inflater;
public String service, typeid;
String result_reso;
List<DataComplaint> data= Collections.emptyList();
DataComplaint current;
int currentPos=0;
MyHolder holder;
public complaintAdapter(Context context, List<DataComplaint> data, String service_id, String type_id){
this.context=context;
inflater= LayoutInflater.from(context);
this.data=data;
this.service = service_id;
this.typeid = type_id;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = inflater.inflate( R.layout.container_complaint, viewGroup, false );
holder = new MyHolder( view );
Log.e( TAG, "holder = " + typeid );
return holder;
}
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, final int i) {
final MyHolder myHolder= (MyHolder) viewHolder;
final DataComplaint current=data.get(i);
myHolder.textcomplaint.setText(current.complaint);
myHolder.textaddress.setText("Reason: " + current.address);
myHolder.textType.setText("Client : " + current.complaint_type);
myHolder.textplace.setText("Location: " + current.location);
myHolder.textticket.setText( current.ticket );
final int value = getItemCount();
if(typeid.equals( "history" )){
myHolder.btn.setVisibility( View.GONE );
myHolder.btn1.setVisibility( View.GONE );
myHolder.btn2.setVisibility( View.GONE );
}
// myHolder.textPrice.setTextColor( ContextCompat.getColor(context, R.color.colorAccent));
if(typeid.equals( "pending" )) {
myHolder.btn.setOnClickListener( new View.OnClickListener() {
@TargetApi(Build.VERSION_CODES.N)
@Override
public void onClick(View v) {
int btn_position = myHolder.getLayoutPosition();
Log.e( TAG, "total position" +btn_position );
Button button = (Button) v;
Calendar calendar = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss " );
String time = format.format( calendar.getTime() );
type = "In-transit";
String tickeid = current.ticket;
Log.e( TAG, "hello = " + service );
new BackgroundWorker().execute( time, service, tickeid, type );
button.setVisibility( View.GONE );
myHolder.btn1.setVisibility( View.VISIBLE );
myHolder.btn2.setVisibility( View.VISIBLE );
}
} );
public int getItemCount() {
return data.size();
}
class MyHolder extends RecyclerView.ViewHolder{
TextView textcomplaint;
TextView textaddress;
TextView textType,textplace, textticket, textreso;
Button btn, btn1, btn2;
int value1;
// create constructor to get widget reference
public MyHolder(View itemView) {
super(itemView);
textcomplaint = (TextView) itemView.findViewById( R.id.textcomplaint );
textaddress = (TextView) itemView.findViewById( R.id.textaddress );
textType = (TextView) itemView.findViewById( R.id.textType );
textticket = (TextView) itemView.findViewById( R.id.ticketid );
textplace = (TextView) itemView.findViewById( R.id.textplace );
btn = (Button) itemView.findViewById( R.id.enter );
btn1 = (Button) itemView.findViewById( R.id.repositry );
btn2 = (Button) itemView.findViewById( R.id.exit );
}
}
Вот мой XML-файл
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="horizontal"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/textcomplaint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@android:color/holo_red_dark"
android:textSize="18sp" />
<TextView
android:id="@+id/ticketid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:visibility="gone" />
<TextView
android:id="@+id/textaddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@android:color/holo_blue_dark"
android:textSize="14sp" />
<TextView
android:id="@+id/textType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:textColor="@android:color/holo_purple"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="@+id/textplace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingTop="20dp"
android:text="TextView"
android:textColor="@android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="80dp"
android:orientation="horizontal">
<Button
android:id="@+id/enter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="In-Trainsit" />
<Button
android:id="@+id/repositry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Reached"
android:visibility="gone" />
<Button
android:id="@+id/exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Logout"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
Здесь мой итогItemCount равен 8, и позиция моей кнопки начинается с 0
Теперь, когда я нажимаю на кнопку с позиционированием 0, все остальные кнопки с 1,2,3,4 ... позиционированием должны быть отключены
Как это сделатьчто
И я хочу использовать только кнопку Нет, флажок и нет переключателя или переключателей
Заранее спасибо