-
المساهمات
89 -
تاريخ الانضمام
-
تاريخ آخر زيارة
نوع المحتوى
ريادة الأعمال
البرمجة
التصميم
DevOps
التسويق والمبيعات
العمل الحر
البرامج والتطبيقات
آخر التحديثات
قصص نجاح
أسئلة وأجوبة
كتب
دورات
أجوبة بواسطة Abdullha Mohammad
-
-
هل في طريقه اخرا غير shared preferences اني احفظ فيه الصفحه واخليه يعرضه لي عند تشغيل التطبيق؟
-
بتاريخ On 5/4/2022 at 02:22 قال Wael Aljamal:
في الدالة get مرر لها وسيط ثاني يعبر عن القيمة الافتراضية للمفتاح في حال تحميل أول Fragment لأن أول تشغيل ستكون قيمته null أي preferences.getString("Fragment", "Frag1");
بحيث إن لم يجد قيمة مقابل المفتاح يعيد مثلا Fragment 1 استبدل المفتاح و القيمة الافتراضية حسب تطبيقك
-
بتاريخ 20 ساعات قال Wael Aljamal:
تعريف الصنف غير ضروري، ما شرحته كان استخدام ملف Strings في المثال..
في الشيفرة التي ارفقتها في هذه الإجابة فقط استبدل الاسم بأي شيء تريده.
- استخدم get في on start
- و put في حال حدوث تعديل لل Fragment التقط حدث التغيير و ضع الشيفرة
وفي Fragment حطيت الأكواد هذا بس غيرت في قيمه الاسم والمفتاح علي حسب الشاشه ا او ٢ او ٣ الخ... في كل Fragment
-
بتاريخ On 1/4/2022 at 10:50 قال Wael Aljamal:
حاول استعمال الشيفرة التالية و تجريبها سوف تخزين اسم فقط، ثم تعرضه
SharedPreferences preferences1 = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = preferences1.edit(); editor.putString("Name","wael"); editor.apply();
ثم عرض إخطار بسيط:
SharedPreferences preferences2 = PreferenceManager.getDefaultSharedPreferences(this); String name = preferences2.getString("Name", ""); Toast.makeText(getActivity(), "Hi! from " + name, Toast.LENGTH_LONG).show();
طيب الحين انا ابيه يعرض لي آخر شاشه كنت فيه بعد ما أعيد فتح التطبيق ، اول شي احفظه اعمله editor.getString و ثمه اروح اسوي preferences.getString. احط كود الارتجاع في onPause و لا onStart او اتبع طريقه الأول الي علمتني فيه اعمل class و اعمل فيه return لل Fragment
-
-
-
-
-
-
-
بتاريخ 2 ساعات قال Wael Aljamal:
عند كل تنقل إلى Fragment ما، علينا حفظ هذا الانتقال مثل الاحتفاظ برقمه مثلاً.
وبذلك عند فتح التطبيق نقرأ قيمة shared preff وفيه رقم آخر Fragment وبذلك نفتحه.
- عملية تحديث رقم Fragment في كل مرة ننتقل لواحد مختلف (مكررة في كل Fragment )
- عملية قراءة الرقم مرة واحدة عند فتح التطبيق (في Fragment الرئيسي الافتراضي) ثم فتح الFragment الهدف
عند فتح التطبيق نطبق التالي:
// قراءة اسم آخر نشاط SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); String activityTag = editor.getString(getString(R.string.last_viewed_activity_tag), null); // نشاط افتراضي في حال فتح التطبيق لأول مرة Class initialActivityClass; // الاختيار حسب المس النشاط switch (activityTag) { case "CoolActivity": initialActivityClass = CoolActivity.class; break; case "WowActivity": initialActivityClass = WowActivity.class; break; default: initialActivityClass = MainActivity.class; break; } // إطلاق النشاط Intent intent = new Intent(this, initialActivityClass); startActivity(intent); finish();
عند تغيير fragment فقط نعمل putString بدل get و نخزن قيمة تدل على Fragment
SharedPreferences preferences = getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); String activityTag = editor.putString(R.string.last_viewed_activity_tag, "Fragment name / number" ); ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Class initialActivityClass
اعمل لك كلاس جديد ولا اقدر احطه داخل Main activity
-
بتاريخ 3 دقائق مضت قال Wael Aljamal:
صحيح نفسه هذه أبسط فكرة
الحين اسوي حق كل Fragment داخله shared preferences ولا اسويه مره وحده في Main activity عشان يستديعه لما افتح التطبيق؟
ولا اسوي كل الأكواد داخل Main activity?
- 1
-
بتاريخ 17 دقائق مضت قال Wael Aljamal:
يمكنك إنشاء كائن shared preference له مفتاح معين لهذه المهمة مثل lastFragment في كل مرة تنقل على صفحة جديدة تقوم بتخزين رقم الصفحة فيه عن طريق الدالة set، و عند بداية التطبيق تقرأ قيمة هذا المفتاح عن طريق get و تقوم بعمل التوجيه لفتح آخر صفحة تم فتحها.
نفس المثال هذا او اذا عندك مثال او فيديو يشرح لي اكثر
- 1
-
مثلا عندي تطبيق وداخله ١٠ شاشه من نوع Fragments وقبل ما اطلع من التطبيق اكون فاتح الشاشه رقم ٨ مثلا فبعد ما افتح التطبيق مره ثاني ابيه يفتح لي دايركت علي الصفحه الي كنت فيه قبل ما اسكر التطبيق
- 1
-
-
-
بتاريخ On 11/11/2021 at 03:26 قال عبود سمير:
عندي مشكله في استخدام مكتبات android x وتصميم matarial
انا قبل فتره كان عندي نفس المشكله وحليته بس الملف انمسح من عندي
هذي تصميم تجريبي بس مايرضا يشتغل عندي
<?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:id="@+id/rv_main" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" > <androidx.appcompat.widget.Toolbar android:layout_width="match_parent" android:layout_height="?actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/Theme.AppCompat.Light"/> </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/scroll" android:clipToPadding="false" app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" > <LinearLayout android:layout_margin="@dimen/activity_horizontal_margin" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <androidx.recyclerview.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/main_rv"/> </LinearLayout> </androidx.core.widget.NestedScrollView> <com.google.android.material.floatingactionbutton.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|end" android:layout_margin="@dimen/main_fab_margin" android:background="@color/design_default_color_primary" android:src="@drawable/ic_launcher_foreground" tools:ignore="SpeakableTextPresentCheck" > </com.google.android.material.floatingactionbutton.FloatingActionButton> </androidx.coordinatorlayout.widget.CoordinatorLayout>
-
بتاريخ On 9/11/2021 at 20:56 قال Abdullha Mohammad:
?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <androidx.cardview.widget.CardView app:cardCornerRadius="20dp" app:cardElevation="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" > <ImageView android:id="@+id/add" android:layout_width="match_parent" android:layout_height="250dp" android:layout_gravity="center" tools:srcCompat="@drawable/ic_launcher_background" /> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="16dp" android:text="cardview" android:textSize="30sp" /> </LinearLayout> </androidx.cardview.widget.CardView> </LinearLayou
t>
بتاريخ On 9/11/2021 at 11:01 قال بلال زيادة:هل يمكنك إرفاق الكود الذي تتوقع أن تكون به مشكلة , حتى نستطيع مساعدتك بشكلٍ أفضل ؟
ممكن ترد علي حضرتك
-
بتاريخ 14 ساعات قال بلال زيادة:
هل يمكنك إرفاق الكود بشكل كامل من غير صور ؟ لكي أستطيع الاطلاع عليه كاملاً .
?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <androidx.cardview.widget.CardView app:cardCornerRadius="20dp" app:cardElevation="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" > <ImageView android:id="@+id/add" android:layout_width="match_parent" android:layout_height="250dp" android:layout_gravity="center" tools:srcCompat="@drawable/ic_launcher_background" /> <TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="16dp" android:text="cardview" android:textSize="30sp" /> </LinearLayout> </androidx.cardview.widget.CardView> </LinearLayou
t>
-
بتاريخ 1 ساعة قال بلال زيادة:
هل يمكنك إرفاق الكود الذي تتوقع أن تكون به مشكلة , حتى نستطيع مساعدتك بشكلٍ أفضل ؟
تمام المسا راح ابعت لك الكود
-
-
-
-
إثبات الهويه في google console
في أسئلة البرمجة
نشر
انا اعيش في السعودية حاولت بعده طرق إثبات الهويه لم ينجح معي جرب الاقامه و الجواز أيضا رخصه السواقه بعد عدت محاوله ظهر لي هذا الصفحه؟