Commit 2f44845a authored by iman Fauzi's avatar iman Fauzi

make payment list selected

parent 5110f6c3
......@@ -40,7 +40,7 @@ public class PaymentActivity extends AppCompatActivity {
RecyclerView rvPayment = findViewById(R.id.rvPayment);
LinearLayoutManager llm = new LinearLayoutManager(this);
LinearLayoutManager llm = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
rvPayment.setLayoutManager(llm);
paymentResponses.add(new PaymentResponse("https://i.ibb.co/RjJQT9K/BNI-logo.png", "cash"));
......
......@@ -6,6 +6,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioButton;
import android.widget.Toast;
import androidx.annotation.NonNull;
......@@ -58,7 +59,8 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.binData(paymentResponses.get(position));
// holder.radioButton.setChecked(position == getPosition);
holder.radioButton.setChecked(position == getPosition);
// final PaymentModel paymentModel = paymentModels.get(position);
//
// ImageView imageView = holder.logoComp;
......@@ -76,15 +78,12 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
}
public class ViewHolder extends RecyclerView.ViewHolder {
MaterialCardView cardView;
PaymentListBinding binding;
public int position;
RadioButton radioButton;
public ViewHolder(@NonNull PaymentListBinding view) {
super(view.getRoot());
this.binding = view;
getPosition = getAdapterPosition();
Log.d("ViewHolder: ", String.valueOf(cardView));
radioButton = view.rbPayment;
}
@SuppressLint("ResourceAsColor")
......@@ -92,13 +91,12 @@ public class PaymentAdapter extends RecyclerView.Adapter<PaymentAdapter.ViewHold
binding.setPayment(paymentResponse);
binding.setLogo(paymentResponse.getUrl());
Log.d("Position ", ""+getAdapterPosition());
binding.cvPayment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("Click VC", paymentResponse.getBank());
binding.cvPayment.toggle();
getPosition = getAdapterPosition();
notifyDataSetChanged();
}
});
}
......
......@@ -19,7 +19,8 @@
android:id="@+id/rvPayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/appbar"/>
app:layout_constraintTop_toBottomOf="@id/appbar"
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnPay"
......
......@@ -67,6 +67,14 @@
app:layout_constraintTop_toTopOf="parent"
/>
<RadioButton
android:id="@+id/rbPayment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment