I want to make custom calendar, and for this I'm using a GridView (with 12 cells for months) with embedded GridViews for every month (showing days of months). I did very simple layout and code just to check how it looks. The problem is that I get 12 cells, but each of them shows only 1 row of inner grid (of month). So it shows like "0 1 2 3 4 5 6" for every cell of 12 (months).
First, it was worse - it was showing just single row of outer grid with single rows of inner grids. After some experimenting, I solved this problem: the issue was with that my main activity had root element of some special class (this was auto-generated by Android studio), I have changed it to LinearLayout and it started showing all cells of outer grid, but still just 1 row of the inner. First, my inner layouts were wrapped in RelativeLayout, I changed them all to LinearLayout hoping this will fix it - but there is no change. I also experimented a bit with widths and heights with no luck, and I have no idea what to try next.
Here are my layouts:
activity_main
<?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="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/calendar_year"></include>
</LinearLayout>
calendar_year (outer grid)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<GridView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/grid_year"
android:numColumns="3"
android:gravity="center"
android:stretchMode="columnWidth" />
</LinearLayout>
calendar_month (inner grid)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<GridView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/grid_month"
android:numColumns="7"
android:gravity="center"
android:stretchMode="columnWidth" />
</LinearLayout>
calendar_day (cell content)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/text_day"
android:textColor="#android:color/black" />
</LinearLayout>
onCreate of MainActivity.java:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
((GridView) this.findViewById(R.id.grid_year)).setAdapter(new YearGridAdapter(getApplicationContext()));
}
Outer grid's adapter:
public class YearGridAdapter extends BaseAdapter {
public YearGridAdapter(Context context) {
this.context = context;
}
#Override
public int getCount() {
return 12;
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.calendar_month, parent, false);
}
GridView monthView = (GridView) convertView.findViewById(R.id.grid_month);
monthView.setAdapter(new MonthGridAdapter(context));
return convertView;
}
private Context context;
}
Inner grid's adapter:
public class MonthGridAdapter extends BaseAdapter {
public MonthGridAdapter(Context context) {
this.context = context;
}
#Override
public int getCount() {
return 30;
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.calendar_day, parent, false);
}
((TextView) convertView.findViewById(R.id.text_day)).setText(Integer.toString(position));
return convertView;
}
private Context context;
}
This is probably caused by having GridView inside of GridView. Since both layouts are scrollable this causes a lot of problems. You can see on this link Arun Antoney's answer which may solve your problem
Related
I want to display a single row of 5 images which then I can click on, this is what I hope to get:
[1][2][3][4][5]
This is what I actually get:"____" is a large, long blank area
[1]________________________
[2]________________________
[3]________________________
[4]________________________
[5]________________________
At first I thought there was something up with the orientation so I tried both "horizontal" and "vertical" but nothing worked.
Here is the adaptor code:
public class CustomTopGridMenuAdaptor extends BaseAdapter {
private Context mContext;
private final int[] gridViewImageId;
private ImageView imageViewAndroid;
public CustomTopGridMenuAdaptor(Context context, int[] gridViewImageId) {
mContext = context;
this.gridViewImageId = gridViewImageId;}
#Override
public int getCount() {
return gridViewImageId.length;
}
#Override
public Object getItem(int i) {
return null;
}
public void setImageSource (int i,ImageView v){
imageViewAndroid.setImageResource(gridViewImageId[i]);
}
#Override
public long getItemId(int i) {
return 0;
}
#Override
public View getView(int i, View convertView, ViewGroup parent) {
View gridViewAndroid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
gridViewAndroid = new View(mContext);
gridViewAndroid = inflater.inflate(R.layout.android_custom_gridview_layout_top, null);
imageViewAndroid = (ImageView)
gridViewAndroid.findViewById(R.id.android_gridview_image_top);
setImageSource(i,imageViewAndroid);
} else {
gridViewAndroid = (View) convertView;
}
return gridViewAndroid;
}
}
As far as it goes the adaptor is working just fine.
This is the xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/android_custom_gridview_layout_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:id="#+id/android_gridview_image_top"
android:layout_width="50dp"
android:layout_height="50dp"/>
</LinearLayout>
This is the xml segment in the activity layout, where the menu will be displayed:
<GridView
android:id="#+id/android_gridview_menu_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="196dp">
Can you tell me why it's not working?
Use the android:numColumns="2" in your GridView if you want 5 then change the android:numColumns="5"
<GridView
android:id="#+id/android_gridview_menu_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffff"
android:numColumns="2"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="196dp">
I don't think that gridviews can be made horizontally scrollable. Android has provided HorizontalScrollView it will scroll your view horizontaly. try this.
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<GridView
android:id="#+id/gridView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</GridView>
</LinearLayout>
</HorizontalScrollView>
Happy coding!!
This question already has answers here:
How to customized the ListView height in android?
(4 answers)
Closed 5 years ago.
I am a beginner to android. I want to display a customized list view which contains a number. I customized my List item height size(android:layout_height="50dp"). But when I run the app it display the size largely which am not given. I don't know how to fix this problem. Could anyone help me?
activity_topic_list.xml
<?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"
android:orientation="vertical"
tools:context="com.example.yuvi.secrectsforhappylife.TopicList">
<ListView
android:id="#+id/topiclist"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
titledesign.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/storylist">
<TextView
android:id="#+id/topictitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/title"
android:textSize="25sp"
android:textStyle="bold"
android:textColor="#android:color/background_light" />
</RelativeLayout>
TopicList.java
public class TopicList extends AppCompatActivity {
String topic\[\]={"one","two","three","four","five","six","seven","eight","nine","ten"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_topic_list);
ListView listView=(ListView)findViewById(R.id.topiclist);
CustomAdapter customAdapter=new CustomAdapter();
listView.setAdapter(customAdapter);
}
class CustomAdapter extends BaseAdapter
{
#Override
public int getCount() {
return topic.length;
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
convertView=getLayoutInflater().inflate(R.layout.titledesign,null);
TextView title=(TextView)convertView.findViewById(R.id.topictitle);
title.setText(topic\[position\]);
return convertView;
}
}
}
Try below code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/storylist">
and make changes in your listview also like below
<ListView
android:id="#+id/topiclist"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Whenever I use a base adapter to add a view to a gallery it causes the EditText from within the view to not allow text input, it focuses and the keyboard appears but when I enter text it doesn't appear. The EditText type is numberDecimal.
I have tried setting the content view of MainActivity to ap_overview_add and the EditText works fine.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.mwapps.baseadaptertest.MainActivity">
<Gallery
android:id="#+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:padding="20dp" />
</RelativeLayout>
ap_overview_add.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="vertical"
android:id="#+id/ap_overview_add_LL"
android:gravity="center">
<EditText
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/ap_et_add"
android:inputType="numberDecimal"
android:padding="10dp"
android:backgroundTint="#color/abc_secondary_text_material_light"
android:imeOptions="actionSend"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:layout_weight=".75"
android:clickable="true"
android:text="300"
android:focusable="true"
android:focusableInTouchMode="true" />
</LinearLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity {
Gallery gallery;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gallery = (Gallery) findViewById(R.id.gallery1);
gallery.setAdapter(new GalleryImageAdapter(this));
}
}
GalleryImageAdapter.java
public class GalleryImageAdapter extends BaseAdapter {
Context mContext;
LayoutInflater inflater;
public GalleryImageAdapter(Context context)
{
mContext = context;
}
public int getCount() {
return 1;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
// Override this method according to your need
public View getView(int index, View view, ViewGroup viewGroup)
{
// TODO Auto-generated method stub
inflater = LayoutInflater.from(mContext);
View tab;
tab = inflater.inflate(R.layout.ap_overview_add, viewGroup, false);
return tab;
}
}
I've looked at other questions similar and nothing has worked, including trying to change the softinput mode, what is causing the text to not be entered?
Edit: If the inputType is changed to text it allows input
Edit 2: If the inputtype is set to numberDecimal, numbers cannot be entered but things like commas can be, so it looks like it's not accepting numbers
You can use ViewPager instead of Gallery as suggested in developer.android.com/reference/android/widget/Gallery.html
to make it work
Hi I am working with custom GridView.
The GridView placed in the following xml/layout file.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<View
android:id="#+id/music_home_ad_view"
android:layout_width="match_parent"
android:layout_height="50dp" />
<ScrollView
android:id="#+id/music_home_root_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ScrollView>
<FrameLayout
android:id="#+id/music_home_promo_frame"
android:layout_width="match_parent"
android:layout_height="#dimen/music_home_promo_height"
android:layout_marginTop="20dp" >
<android.support.v4.view.ViewPager
android:id="#+id/music_home_promo_pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.raaga.home.CirclePageIndicator
android:id="#+id/music_home_page_indicator"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_gravity="bottom"
android:padding="10dp" />
</FrameLayout>
<GridView
android:id="#+id/music_home_grid_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/music_home_promo_frame"
android:numColumns="3" >
</GridView>
</RelativeLayout>
The GridView contains the following views
music_grid_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
>
<ImageView
android:id="#+id/music_grid_image"
android:layout_width="60dp"
android:layout_height="70dp"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:layout_marginTop="10dp"
android:src="#drawable/new_releases"
/>
<TextView
android:id="#+id/music_grid_category_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/music_grid_image"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="New Releases"
android:textColor="#color/text_white"
/>
</RelativeLayout>
I have used the custom adapter class and followed this link
MusicCategoryAdapter.java
public class MusicCategoryAdapter extends BaseAdapter{
ArrayList<Integer> categoryImageList;
ArrayList<String> categoryNameList;
Context mContext;
public MusicCategoryAdapter(Context mContext, ArrayList<Integer> categoryImageList, ArrayList<String> categoryNameList) {
this.mContext= mContext;
this.categoryImageList = categoryImageList;
this.categoryNameList = categoryNameList;
}
#Override
public int getCount() {
//send the list length
return categoryImageList.size();
}
#Override
public Object getItem(int position) {
return null;
}
#Override
public long getItemId(int position) {
return 0;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
GridHolder holder;
View grid = convertView;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
convertView = inflater.inflate(R.layout.music_grid_item, null);
holder = new GridHolder();
holder.categoryTitle = (TextView) convertView.findViewById(R.id.music_grid_category_name);
holder.categoryImage = (ImageView)convertView.findViewById(R.id.music_grid_image);
holder.categoryTitle.setText(categoryNameList.get(position));
holder.categoryImage.setImageResource(categoryImageList.get(position));
convertView.setTag(holder);
} else {
holder = (GridHolder) convertView.getTag();
}
return convertView;
}
public class GridHolder{
ImageView categoryImage;
TextView categoryTitle;
}
}
I am facing the problem that the items are repeating by changing the position when scrolling.
Could anyone help on this problem? What mistake I did in this?
Put the scrollview at the starting of relative layout and end the tag in the end of the relative layout.
This would make your entire layout scrollable and you will overcome the problem.
I tried to use a ListFragment with a custom layout: Simple static headline, below the ListContent given with the SimpleCursorAdapter. The list itself also has a custom layout. The SimpleCursorAdapter works (Query is fine, Custom Layout for List works). As long as I do not use custom layout for the Fragment itself, everything works fine.
If I add the layout for the Fragment, only the headline (Textview) works, the list keeps empty.
Custom Layout for the List:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" >
</TextView>
<TextView
android:id="#+id/value"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_gravity="right"
android:textSize="20sp" >
</TextView>
Custom Layout for the Fragment:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/last_update"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</TextView>
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
<TextView android:id="#id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:text="No data">
</TextView>
I commented some stuff out - it was worth a try because i read that it helped - for me it was not helping.
Last bot not least the Code of the Fragment:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.viewfragment, container, false);
}
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
TableDataGateway tableGate = new TableDataGateway(getActivity());
tableGate.UpdateUIRecords();
TextView tv = (TextView) getView().findViewById(R.id.last_update);
tv.setText(tableGate.getLastUpdateDate());
Cursor cursor = tableGate.selectUIRecords();
dBadapter = new SimpleCursorAdapter(getActivity(), R.layout.viewlayout, cursor, new String[] { DB_COL_GUI_LABEL, DB_COL_LAST_KNOWN_VALUE }, new int[] { R.id.label, R.id.value }, 0);
super.setListAdapter(dBadapter);
}
Question is: Why is the ListAdapter not connecting with the fragment layout?
Regards
Flizz
CLARIFICATION OF THE PROBLEM
I have a similar problem like Android + ListFragment with a custom view hierarchy
But i do not have stacked the content over each other, i only see the TextView content in the top corner of the screen and below where the list should be is just a white background.
I was pretty sure to have done anything as Google told to do (http://developer.android.com/reference/android/app/ListFragment.html keyword Screen Layout)
Update:
I am unsure whether i have to change my main_activity.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
I have not considered the fragment in there, do not know whether this is needed. Yesterday i tried a few functions to understand my problem in detail. I used getView().isShown() and get the return FALSE - this seems wrong to my, but I have no clue what is wrong here ...
Your ListView id must be #android:id/list in a ListFragment.
Maybe you should also replace super.setListAdapter to just setListAdapter.
Hey Here is a snippet of correct usage of CustomAdapter:
private class MyCustomAdapter extends BaseAdapter {
private ArrayList<String> mData = new ArrayList<String>();
private LayoutInflater mInflater;
public MyCustomAdapter() {
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public void addItem(final String item) {
mData.add(item);
notifyDataSetChanged();
}
#Override
public int getItemViewType(int position) {
if(position < LIST_ITEM_TYPE_1_COUNT)
return LIST_ITEM_TYPE_1;
else
return LIST_ITEM_TYPE_2;
}
#Override
public int getViewTypeCount() {
return LIST_ITEM_TYPE_COUNT;
}
#Override
public int getCount() {
return mData.size();
}
#Override
public String getItem(int position) {
return mData.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
int type = getItemViewType(position);
if (convertView == null) {
holder = new ViewHolder();
switch(type) {
case LIST_ITEM_TYPE_1:
convertView = mInflater.inflate(R.layout.list_item_type1, null);
holder.textView = (TextView)convertView.findViewById(R.id.list_item_type1_text_view);
break;
case LIST_ITEM_TYPE_2:
convertView = mInflater.inflate(R.layout.list_item_type2, null);
holder.textView = (TextView)convertView.findViewById(R.id.list_item_type2_button);
break;
}
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
holder.textView.setText(mData.get(position));
return convertView;
}
}
public static class ViewHolder {
public TextView textView;
}
}
After reviewing
Blank ListView with SimpleCursorAdapter
http://developer.android.com/samples/CustomChoiceList/src/com.example.android.customchoicelist/MainActivity.html
http://developer.android.com/samples/CustomChoiceList/res/layout/sample_main.html
i found the solution - everything is right so far. I just messed up the layout file:
Both contents ListView as TextView had the value "match_parent" - so there was not enough layout room for the other component. The component which comes first in the layout file overwrites everything else.
I adjusted the layout file to this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
</ListView>
<TextView android:id="#android:id/empty"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#FF0000"
android:text="No data">
</TextView>
<TextView
android:id="#+id/last_update"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>
</LinearLayout>
and everything works fine. Do NOT use the fragment layout for the activity - it should have its own layout, else it will lead to errors.
Thanks everybody for helping.
Rgds
Flizz