*thanks for the reply, doug.  Here's the code, I'm having the same issue 
with every button in the listview.*
*
*
*main_menu.xml*

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"; 
android:orientation="vertical" style="@style/body" >

<ImageView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:scaleType="center" 
android:src="@drawable/logo_small" />


<ListView 
android:id="@+id/ListView_Menu" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:contentDescription="Main Menu" 
android:scrollbarAlwaysDrawVerticalTrack="true" 
android:divider="#00000000" 
/>


</LinearLayout>
*
*
*menu_item.xml*

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android";
    android:textColor="@color/btn_blue_text"
    android:textSize="14px"    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="5px"
    android:paddingBottom="5px"
    android:text="test string"
    android:layout_gravity="center_horizontal"
    android:gravity="center"
    android:background="@drawable/btn_blue"
/>

*this is the method that populates the listview*

public void PopulateGrid(final String strPersonID) {
     ListView menuList = (ListView) findViewById(R.id.ListView_Menu);
        String[] items = {getResources().getString(R.string.menu_Vitals_My),
                getResources().getString(R.string.menu_Vital_Add),
                getResources().getString(R.string.menu_Resources),
                getResources().getString(R.string.menu_Log_Out)};
        ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, 
R.layout.menu_item, items);
        menuList.setAdapter(adapt);
        menuList.setOnItemClickListener(new 
AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View itemClicked, 
int position, long id) {
                TextView textView = (TextView) itemClicked;
                String strText = textView.getText().toString();
                if 
(strText.equalsIgnoreCase(getResources().getString(R.string.menu_Vitals_My))) 
{
                    // MY VITALS
                 Intent myIntent = new Intent(MainMenuActivity.this, 
VitalsMyActivity.class);
             myIntent.putExtra("PersonID", strPersonID);
                    startActivityForResult(myIntent, 0);
                } else if 
(strText.equalsIgnoreCase(getResources().getString(R.string.menu_Vital_Add))) 
{
                    // ADD VITAL
                    startActivity(new Intent(MainMenuActivity.this, 
VitalAddActivity.class));
                } else if 
(strText.equalsIgnoreCase(getResources().getString(R.string.menu_Resources))) 
{
                    // RESOURCES
                    startActivity(new Intent(MainMenuActivity.this, 
ResourcesActivity.class));
                } else if 
(strText.equalsIgnoreCase(getResources().getString(R.string.menu_Support))) 
{
                    // SUPPORT
                    startActivity(new Intent(MainMenuActivity.this, 
SupportActivity.class));
                }else if 
(strText.equalsIgnoreCase(getResources().getString(R.string.menu_Log_Out))) 
{
                    // LOG OUT
                 //delete user info
                 SharedPreferences prefs = 
getSharedPreferences("UserInfo",0);
                 SharedPreferences.Editor prefsEditor = prefs.edit();
                 prefsEditor.remove("PersonID");
                 prefsEditor.commit();

                    startActivity(new Intent(MainMenuActivity.this, 
MainActivity.class));
                }
            }
        });
    }
    

-- 
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