ياإخوان كيف أستطيع تغيير لون خط الـ List وألف ألف شكر مقدمًا
حاولت كثيرًا ولكن بدون فائدة
ياإخوان كيف أستطيع تغيير لون خط الـ List وألف ألف شكر مقدمًا
حاولت كثيرًا ولكن بدون فائدة
تم تعديل هذه المشاركة بواسطة هدف الشمالي في 24 ديسمبر 2011 في 17:52
أولاً ما هكذا تكون الأسئلة، على الأقل ضع كوداً لنستطيع التعامل معه.
ثانياً: بالنسبة للون الخط داخل القائمة. عادة ListView تكون وعائاً لواجهات أخرى كالـTextView وغيرها ومن خلال تلك الواجهات يمكنك تغيير اللون والشكل وأي شيء تريد.
انظر إلى هذا المثال:
هنا ListView تكون داخل ملف الهيكل Layout:
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:listSelector="@color/list_selector"
android:divider="@drawable/grade"
android:dividerHeight ="1dp"
android:cacheColorHint="#00000000"
>ومن ثم في الكلاس الممتد من ListActivity تضع هذا الكود:
public class MyListAdapter extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_list_activity_view);
// Query for all people contacts using the Contacts.People convenience class.
// Put a managed wrapper around the retrieved cursor so we don't have to worry about
// requerying or closing it as the activity changes state.
mCursor = this.getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(mCursor);
// Now create a new list adapter bound to the cursor.
// SimpleListAdapter is designed for binding to a Cursor.
ListAdapter adapter = new SimpleCursorAdapter(
this, // Context.
android.R.layout.two_line_list_item, // في هذا السطر تضع المعرف الخاص بالواجهة التي تريدها
mCursor, // Pass in the cursor to bind to.
new String[] {People.NAME, People.COMPANY}, // Array of cursor columns to bind to.
new int[] {android.R.id.text1, android.R.id.text2}); // Parallel array of which template objects to bind to those columns.
// Bind to our new adapter.
setListAdapter(adapter);
}
}تم تعديل هذه المشاركة بواسطة khr2003 في 24 ديسمبر 2011 في 18:28