Results 1 to 1 of 1
  1. #1
    KernelPanic is offline Member
    Join Date
    Apr 2012
    Posts
    16
    Rep Power
    0

    Angry Activity's ListView items do not show

    Dear Sirs and Madams!

    In my first Android app, I have an activity with ListView, which contens are not shown. At the app launch, I have a splash screen, which then switches to main activity, which should show listview with three string elements. Why string elements are not shown? Here is a code of CMainActivity's xml build:
    Java Code:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ListView android:id="@+android:id/listview_mainscreen"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:drawSelectorOnTop="false"
        />
    </LinearLayout>
    Here is CMainActivity's java code:
    Java Code:
    *
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package com.oljedirekt.trgovko.main;
    import android.app.ListActivity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    import com.oljedirekt.trgovko.R;
    
    /**
     *
     * @author markofr
     */
    public class CActivityMainScreen extends ListActivity
    {
        private static final String m_strLogTag="CActivityMainScreen";
    
        private static final String[] items={
                                                "Iskanje produktov",
                                                "Nakupovalna košarica",
                                                "O programu"
                                            };
    
        @Override
        public void onCreate(Bundle icicle)
        {
            try
            {
                super.onCreate(icicle);
                setContentView(R.layout.cactivitymainscreen);
    
                ListView mainScreenListView=(ListView)findViewById(R.id.listview_mainscreen);
    
                mainScreenListView.setAdapter(new ArrayAdapter<String>(this,
                                              R.layout.citemmainscreen,
                                              items));
            }
            catch(Exception ex)
            {
                String strClassName=ex.getClass().getName().toString();
                String strMessage=ex.getMessage().toString();
    
                Log.wtf(CActivityMainScreen.m_strLogTag,
                        strClassName+":"+
                        strMessage);
    
    /*
                Log.wtf(CActivityMainScreen.m_strLogTag,
                        ex.getClass().getName()+":"+
                        ex.getMessage().toString());
    */
            }
            finally
            {
            }   // try-catch-finally
        }   // onCreate
    
        @Override
        public void onListItemClick(ListView parent,
                                    View v,
                                    int position,
                                    long id)
        {
        }   // onListItemClick
    }
    Here is xml build of listview's row:
    Java Code:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TextView android:id="@+id/item_mainscreen_text"
                android:gravity="center"
                android:textSize="22dip"
                android:textColor="#ffffff"
                android:textStyle="bold"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
            />
    </LinearLayout>
    And here is activity transition code (from SplashScreen to MainActivity):
    Java Code:
    try
                        {
                            Intent intent=new Intent(CActivitySplashScreen.this,
                                                     CActivityMainScreen.class);
                            startActivity(intent);
                        }
                        catch(Exception ex)
                        {
                            Log.wtf(CActivitySplashScreen.m_strLogTag,
                                    ex.getClass().getName()+":"+
                                    ex.getMessage().toString());
                        }
                        finally
                        {
                        }   // try-catch-finally
    Now, why listview's items are not shown????

    Sincerely,
    Marko
    Last edited by KernelPanic; 05-17-2012 at 08:24 AM.

Similar Threads

  1. Replies: 8
    Last Post: 12-10-2011, 05:54 PM
  2. Replies: 0
    Last Post: 10-01-2011, 05:14 AM
  3. ListView Sub Items
    By rolledback in forum Android
    Replies: 2
    Last Post: 09-21-2011, 10:21 PM
  4. Replies: 1
    Last Post: 09-12-2011, 03:09 AM
  5. listView and listArray methods
    By viviosoft in forum Android
    Replies: 0
    Last Post: 09-09-2011, 11:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •