I am building an "About" dialog that will appear as a PreferenceFragment in 
my application.  I believe I have everything "wired" properly as I'm 
getting a toast comment when I load my About preference fragement, however, 
the data I load in my SimpleAdapter doesn't appear.  Below are my various 
code bits that should help.  
 
I am quite new to Android development, so if you have other ideas about how 
I can go about achieving my goals (a multicolumn listview to display 
information about the application (company, version, etc.), then please let 
me know where I can go to get examples, etc.
 
Thanks in Advance!!! 
B.
 
preference_header.xml
~~~~~~~~~~~~~~~~~~


<preference-header>

...

<header

android:fragment="com.mycompany.myapp.AboutFragment"

android:title="About My App"

android:summary="Information about my app"/>

</preference-header>

 
about_list_view.xml
~~~~~~~~~~~~~~~~~~~
<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"; 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" > 

<ListView android:id="@+id/ABOUT_LIST" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000fff" 
android:layout_weight="2" 
android:drawSelectorOnTop="false"> 
</ListView> 

<TextView android:id="@id/android:empty" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#FFff00" 
android:text="No data" 
/> 
</LinearLayout>
 
AboutFragment.java
~~~~~~~~~~~~~~~~
public class AboutFragment extends PreferenceFragment 
{  
public AboutFragment() 
{ 
} 

@Override 
public void onCreate(Bundle aSavedState) 
{ 
   super.onCreate(aSavedState); 
   Context anAct = getActivity().getApplicationContext(); 
   Toast.makeText(anAct, "About!", Toast.LENGTH_SHORT).show(); 
 } //onCreate 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
Bundle savedInstanceState) 
{ 
   View v = inflater.inflate(R.layout.about_list_view, null); 
   ListView viewAboutList = (ListView)v.findViewById(R.id.ABOUT_LIST); 
   ArrayList<HashMap<String, String>> aboutList = new 
ArrayList<HashMap<String, String>>();    
   HashMap<String, String> map = new HashMap<String, String>(); 
   map.put("title", "Version"); 
   map.put("content", "1.0"); 
   aboutList.add(map); 
   map = new HashMap<String, String>(); 
   map.put("title", "Company"); 
   map.put("content", "Red Wagon Software"); 
   aboutList.add(map); 

   SimpleAdapter aboutAdapter = new 
SimpleAdapter(getActivity().getApplicationContext() , aboutList , 
R.layout.about_row_view, 
   new String[] {"title", "content"}, new int[] {R.id.aboutTitle, 
R.id.aboutContent}); 
   viewAboutList.setAdapter(aboutAdapter); 

   return v; 
} 


} //class AboutFragment

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to