Hi,
i am a totaly newbie with android. Right now just playing around.
Bellow my actual experimental source.
My Questions:
1. How to make the ListView show the full content
( i had in Listview:
android:layout_height="wrap_content" />
and tried also:
android:layout_height="fill_parent" />
but both only gave the the first Listview Item
) so i tricked with high = 5300px just to see how it could looks like.
How to make this dynamicly?
2. Its quit funny. The first entry is the Gallery, but when my Application starts,
the Gallery is already scrolled up and the screen starts with the Listview.
How to fix, that the display start from the top?
Thanks
--------------- checklister.java
package com.checklister.main;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
public class checklister extends Activity
{
private static final String TAG = "CheckLister";
private TextView gallerytext;
private TextView gallerytext2;
private ListView myShoppingList;
private String[] mTexte ={ "Brücke", "Krone", "Inlay", "Zahnarzt", "einer", "wie", "keiner", "gel !!" };
private String[] mTexte2 ={ "Mehrere Zähne werden hier übereinander", "Ein Zahn wird mit einer Krone", "Auffüllen eines Zahnes", "Der Mann hinter dem Bohrer ", "einer", "wie", "keiner", "gel !!" };
private String[] mStrings = {
"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",
"Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale",
"Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese",
"Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell",
"Aragon", "Ardi Gasna", "Ardrahan", "Armenian String", "Aromes au Gene de Marc",
"Asadero", "Asiago", "Aubisque Pyrenees", "Autun", "Avaxtskyr", "Baby Swiss",
"Babybel", "Baguette Laonnaise", "Bakers", "Baladi", "Balaton", "Bandal", "Banon",
"Barry's Bay Cheddar", "Basing", "Basket Cheese", "Bath Cheese", "Bavarian Bergkase",
"Baylough", "Beaufort", "Beauvoorde", "Beenleigh Blue", "Beer Cheese", "Bel Paese",
"Bergader", "Bergere Bleue", "Berkswell", "Beyaz Peynir", "Bierkase", "Bishop Kennedy",
"Zamorano", "Zanetti Grana Padano", "Zanetti Parmigiano Reggiano"};
private Context mContext;
private Integer[] mImageIds =
{ R.drawable.gallery_photo_1, R.drawable.gallery_photo_2,
R.drawable.gallery_photo_3, R.drawable.gallery_photo_4,
R.drawable.gallery_photo_5, R.drawable.gallery_photo_6,
R.drawable.gallery_photo_7, R.drawable.gallery_photo_8 };
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(TAG, " *------- Entered onCreate -------* ");
gallerytext = (TextView) findViewById(R.id.gallery_underline1);
gallerytext2 = (TextView) findViewById(R.id.gallery_underline2);
myShoppingList = (ListView)findViewById(R.id.shoppinglist);
// Reference the Gallery view
Gallery g = (Gallery) findViewById(R.id.gallery);
// Set the adapter to our custom adapter (below)
g.setAdapter(new ImageAdapter(this));
myShoppingList.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mStrings));
// Set a item click listener, and just Toast the clicked position
g.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v,
int position, long id)
{
Toast.makeText(checklister.this, "Opening Video: " + position,
Toast.LENGTH_SHORT).show();
// call Video
Intent i = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.parse("http://www.xxxx.com/3gp/3-iPhone-cell.3gp");
i.setDataAndType(u, "video/*");
startActivity(i);
}
});
// We also want to show context menu for longpressed items in the
// gallery
registerForContextMenu(g);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo)
{
menu.add(R.string.gallery_2_text);
}
@Override
public boolean onContextItemSelected(MenuItem item)
{
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
Toast.makeText(this, "Longpress: " + info.position, Toast.LENGTH_SHORT)
.show();
return true;
}
public class ImageAdapter extends BaseAdapter
{
int mGalleryItemBackground;
public ImageAdapter(Context c)
{
mContext = c;
// See res/values/attrs.xml for the <declare-styleable> that defines
// Gallery1.
TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
mGalleryItemBackground = a.getResourceId(
R.styleable.Gallery1_android_galleryItemBackground, 0);
a.recycle();
}
public int getCount()
{
return mImageIds.length;
}
public Object getItem(int position)
{
return position;
}
public long getItemId(int position)
{
gallerytext.setText("" + mTexte[position]);
gallerytext2.setText("" + mTexte2[position]);
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
ImageView i = new ImageView(mContext);
i.setImageResource(mImageIds[position]);
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setLayoutParams(new Gallery.LayoutParams(136, 88));
// The preferred Gallery item background
i.setBackgroundResource(mGalleryItemBackground);
return i;
}
}
}
------------ main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TableLayout
android:id="@+id/widget29"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<Gallery android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
/>
<TextView
android:id="@+id/gallery_underline1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="16sp"
android:textStyle="bold"
android:text="Picture Info helloo"
/>
<TextView
android:id="@+id/gallery_underline2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Seconde Line of Picture"
android:gravity="center_horizontal"
/>
<ListView
android:id="@+id/shoppinglist"
android:layout_width="fill_parent"
android:layout_height="5300px" />
</TableLayout>
</ScrollView>


