مشکل در recyclerview و cardview
-
مطالب مشابه
-
توسط scientific
سلام وقت بخیر
من در یکی از لیوت ها که مربوط به لیوت آیتم هام میشه از متریال کاردویو استفاده کردم و برنامه م به محض اجرا بسته میشه...
وقتی از خود کاردویو ی Androidx استفاده می کنم برنامه اجرا میشه و آیتم ها رو داخل ریسایکلرویو نشون میده.
توی لاگ کت به کلاس materialCardview اندروید خطا می گیره بازش کردم دیدم R ها رو نمیشناسه :
(عکس خود کلاسش رو هم پیوست کردم.)
at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:78) at com.google.android.material.card.MaterialCardView.<init>(MaterialCardView.java:128) at com.google.android.material.card.MaterialCardView.<init>(MaterialCardView.java:118) ... 66 more دپندسی متریال رو اضافه می کنم ولی بازم تاثیری نداره:
کل دپندنسی ها:
dependencies { def nav_version = "1.0.0-alpha06" implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "androidx.appcompat:appcompat:${var}" implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.13-beta-3' androidTestImplementation 'androidx.test:runner:1.3.0-alpha02' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02' implementation 'me.relex:circleindicator:2.1.2' implementation 'com.google.android.material:material:1.1.0-alpha08' implementation 'de.hdodenhof:circleimageview:3.0.0' implementation 'com.github.bumptech.glide:glide:4.7.1' implementation 'com.android.support:appcompat-v7:29.0.0' //implementation 'androidx.appcompat.app.ActionBarDrawerToggle' //implementation 'androidx.appcompat.app' //implementation 'androidx.cardview:cardview:1.0.0' //implementation 'com.android.support:cardview-v7:29.0.0' //implementation 'com.android.support:design:28.0.0' implementation "android.arch.navigation:navigation-fragment:$nav_version" implementation "android.arch.navigation:navigation-ui:$nav_version" implementation 'androidx.drawerlayout:drawerlayout:1.0.0' } لیوتی که دراون از متریال کاردویو استفاده کردم (لیوت آیتم ها) :
<?xml version="1.0" encoding="utf-8"?> <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" app:contentPadding="8dp" app:cardElevation="4dp" android:layout_marginTop="5dp" android:background="@color/green5"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/course_education_icon" android:layout_width="@dimen/circle_whidth_height" android:layout_height="44dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/course_education_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:layout_marginEnd="8dp" android:textSize="@dimen/textSize_nav_info" android:textColor="@color/colorPrimaryDark" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/course_education_icon" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </com.google.android.material.card.MaterialCardView> کلاس مربوط به متریال کاردویو خود اندروید رو هم پیوست کردم.
ممنون میشم راهنمایی کنید چطور می تونم از متریال کاردویو استفاده کنم؟
-
توسط scientific
سلام وقت بخیر
من در یکی از لیوت ها که مربوط به لیوت آیتم هام میشه از متریال کاردویو استفاده کردم و برنامه م به محض اجرا بسته میشه...
وقتی از خود کاردویو اندروید ایکس استفاده می کنم برنامه اجرا میشه و آیتم ها رو داخل ریسایکلرویو نشون میده
توی لاگ کت به کلاس materialCardview اندروید خطا می گیره بازش کردم دیدم R ها رو نمیشناسه :
(عکس خود کلاسش رو هم پیوست کردم.)
at com.google.android.material.internal.ThemeEnforcement.obtainStyledAttributes(ThemeEnforcement.java:78) at com.google.android.material.card.MaterialCardView.<init>(MaterialCardView.java:128) at com.google.android.material.card.MaterialCardView.<init>(MaterialCardView.java:118) ... 66 more
دپندسی متریال رو اضافه می کنم ولی بازم تاثیری نداره:
dependencies { def nav_version = "1.0.0-alpha06" implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "androidx.appcompat:appcompat:${var}" implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' testImplementation 'junit:junit:4.13-beta-3' androidTestImplementation 'androidx.test:runner:1.3.0-alpha02' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02' implementation 'me.relex:circleindicator:2.1.2' implementation 'com.google.android.material:material:1.1.0-alpha08' implementation 'de.hdodenhof:circleimageview:3.0.0' implementation 'com.github.bumptech.glide:glide:4.7.1' implementation 'com.android.support:appcompat-v7:29.0.0' //implementation 'androidx.appcompat.app.ActionBarDrawerToggle' //implementation 'androidx.appcompat.app' //implementation 'androidx.cardview:cardview:1.0.0' //implementation 'com.android.support:cardview-v7:29.0.0' //implementation 'com.android.support:design:28.0.0' implementation "android.arch.navigation:navigation-fragment:$nav_version" implementation "android.arch.navigation:navigation-ui:$nav_version" implementation 'androidx.drawerlayout:drawerlayout:1.0.0' } این لیوتی که دراون از متریال کاردویو استفاده کردم (لیوت آیتم ها):
<?xml version="1.0" encoding="utf-8"?> <com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" app:contentPadding="8dp" app:cardElevation="4dp" android:layout_marginTop="5dp" android:background="@color/green5"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <de.hdodenhof.circleimageview.CircleImageView android:id="@+id/course_education_icon" android:layout_width="@dimen/circle_whidth_height" android:layout_height="44dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/course_education_txt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:layout_marginEnd="8dp" android:textSize="@dimen/textSize_nav_info" android:textColor="@color/colorPrimaryDark" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/course_education_icon" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout> </com.google.android.material.card.MaterialCardView> کلاس مربوط به متریال کاردویو خود اندروید رو هم پیوست کردم.
ممنون میشم راهنمایی کنید چطور می تونم از متریال کاردویو استفاده کنم؟
-
توسط scientific
سلام ،
من وقتی در MainActivity یه آبجکت از کلاس مدلم می سازم و داده هام رو به پارامترهای constructor اش می فرستم تا در کلاس مدل ذخیره بشه ،
و هم زمان اون اطلاعات رو داخل یک لیست از کلاس مدل هم ذخیره می کنم، برنامه م به محض اجرا بسته میشه
مگر این که کد مربوط به این کار رو کامنت کنم:
courseModelList.add(new CourseModel(image,s)); یا این که باید کد مربوط به "ست شدن آداپتر به ریسایکلرویو" رو کامنت کنم تا برنامه اجرا بشه:
recyclerView_course_main.setAdapter(adapterRecyclerView); --------------------------------------------------------------------------------------------------------------------------
هرکار می کنم ریسایکلرویو رو توی برنامه م نمیتونم نشون بدم
بریک پوینت هم گذاشتم و لاگ کت رو چک کردم ولی بازم نتونستم ایرادش رو برطرف کنم
عکسهایی از کد ها و اجرای خط به خط رو میزارم اگه راهنمایی کنید ممنون میشم:
1- کلاس MainActivity متد مربوط به پر کردن لیست آرایه و ست کردن آداپتر:
private void setupRecyclerView() { courseModelList.add(new CourseModel(image,s)); courseModelList.add(new CourseModel(image,s)); recyclerView_course_main = findViewById(R.id.recyclerView_coursemain); adapterRecyclerView = new AdapterRecyclerView(courseModelList); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); recyclerView_course_main.setLayoutManager(linearLayoutManager); recyclerView_course_main.setAdapter(adapterRecyclerView); } 2- کلاس آداپتر:
3- کلاس مدل:
public class CourseModel { private int cuorse_education_icon; private String course_education_title; public CourseModel(int cuorse_education_icon, String course_education_title) { this.cuorse_education_icon = cuorse_education_icon; this.course_education_title = course_education_title; } public int getCuorse_education_icon() { return cuorse_education_icon; } public String getCourse_education_title() { return course_education_title; } 4- کلاس ViewHolder
import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.donyaeayandeh.itroducingdonyaeayandehinstitute.R; import de.hdodenhof.circleimageview.CircleImageView; public class CourseEducationViewHolder extends RecyclerView.ViewHolder { public CircleImageView course_education_image; public TextView course_education_txt; public CourseEducationViewHolder(@NonNull View itemView) { super(itemView); course_education_image = itemView.findViewById(R.id.course_education_icon); course_education_txt= itemView.findViewById(R.id.course_education_txt); } }
-
توسط Seyed-Hossein-Akbari
برای استفاده از کتابخانه ی ExpandableCardView وارد سایت زیر در گیت شوید .
https://github.com/shakbari435/ExpandableCardView
التماس دعای فرج یا علی
-
توسط sobhan
سلام
من واسه فیلتربندی کتاب هام و دسته بندی کتاب هام از 2تا ریسایکلرویوو استفاده کردم یعنی یکی برای دسته ها و یکی هم برای خود کتاب ها
و واسه اینکه روی هرکدوم از دسته بندی ها که کلیک شد کتاب های اون دسته رو نشون بده از Broadcast استفاده کردم یعنی مقدار رو از آداپتر دسته بندی ها میگیرم و میارم توی آداپتر کتاب ها
و بعد از اینکه یه دسته رو انتخاب کرد اون ایتم هایی رو که جزو اون دسته هستند visible و بقیه gone شند
حالا مشکل من اینجاست که وقتی توی یک دسته بندی هستم و چندتا کتاب رو اضافه میکنم، وقتی میرم توی یه دسته بندی دیگه و دوباره برمیگردم توی دسته بندی قبلی، تعدادش رو صفر نشون میده ☹️
البته وقتی میزنم مشاهده سبدخرید (یعنی مرحله بعد)، همه چیز درسته یعنی کتاب ها و تعدادشون درست نشون میده
این رو هم اضافه کنم که دیتاهارو از وبسرویس میگیرم و میریزم توی دیتابیس اپ و بعد از دیتابیس توی ریسایکلرویوو نمایشش میدم
واسه هرکدوم از کتاب هایی که تعدادشون رو هم زیاد و کم میکنم توی دیتابیسم ذخیره میشه
میشه راهش رو بهم بگین☹️
-
-
فایل
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .