Я начинающий разработчик Android и застрял с этой проблемой.Для любого, кто использовал библиотеку Mindorks, возможно, вы сможете посоветовать, как это сделать.
Код, используемый ниже:
@Layout(R.layout.tinder_card_view)
public class TinderCard {
@View(R.id.profileImageView)
private ImageView profileImageView;
@View(R.id.nameAgeTxt)
private TextView nameAgeTxt;
@View(R.id.locationNameTxt)
private TextView locationNameTxt;
@View(R.id.profileInfo)
private ImageButton info;
@Click(R.id.profileInfo)
void openProfile()
{
//Call the fragment method
}
private Profile mProfile;
private Context mContext;
private SwipePlaceHolderView mSwipeView;
public TinderCard(Context context, Profile profile, SwipePlaceHolderView swipeView) {
mContext = context;
mProfile = profile;
mSwipeView = swipeView;
}
@Resolve
private void onResolved(){
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Bitmap bitmap = mProfile.getImage();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Glide.with(mContext).load(byteArray).asBitmap().into(profileImageView);
//profileImageView.setImageBitmap(mProfile.getImage());
nameAgeTxt.setText(mProfile.getName() + ", " + mProfile.getAge());
locationNameTxt.setText(mProfile.getLocation());
}
У меня ограниченное понимание библиотеки Mindorks.Моя цель состоит в том, чтобы макет tinder_card_view имел кнопку, которая открывала бы DialogFragment, который отображал бы профиль пользователя.
Как я смогу это сделать?TinderCard - это простой класс данных, который не является ни Fragment, ни Activity, но используемый им макет не входит в область действия ParentFragment, поэтому вызов onClickListener в ParentFragment из этого класса выглядит невозможным.
Явызов mSwipeView.addView (новая TinderCard (mContext, профиль, mSwipeView));в моем родительском фрагменте, чтобы создать карту TinderCard и поместить ее в мой SwipePlaceHolderView (класс Mindorks), в котором будут храниться карты Tinder.
Исходное учебное пособие находится здесь: https://blog.mindorks.com/android-tinder-swipe-view-example-3eca9b0d4794
Примечание.аннотация, которая устанавливает onClickListener для элемента, определенного в круглых скобках.(Думаю)