English 中文(简体)
Android 概 述
原标题:Android Listview width prob

以下是屏幕的主要布局:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/splashContent"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/splashscreenbg">
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight=".008"
        android:gravity="center"
        android:background="@drawable/mbstabtitle_bg"
        android:paddingTop="5dip" 
        android:paddingBottom="5dip">
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center" >
            <TextView
                android:id="@+id/mbstabtitle_bg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:textStyle="bold"
                android:text="Please Select Your Location"
                android:textColor="#FFFFFF">
            </TextView>     
        </LinearLayout>
    </TableRow>
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="top"
        android:layout_weight=".99">
        <ListView
            android:id="@+id/locationlist"
            android:background="#7B0326"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        </ListView>
    </TableRow>
</TableLayout>

这里是用来填写名单的改编者。

class LocationAdapter extends BaseAdapter {
        private Activity activity;
        private String[][] data;
        private LayoutInflater inflater=null;

        public LocationAdapter(Activity a, String[][] d) {
            activity = a;
            data=d;
            inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        public int getCount() {
            return data.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            View vi=convertView;
            ViewHolder holder;
            if(convertView==null){
                vi = inflater.inflate(R.layout.locationitem, null);
                holder=new ViewHolder();
                holder.locationName=(TextView)vi.findViewById(R.id.locationName);

                vi.setTag(holder);
                if(position%2 == 0)
                    vi.setBackgroundColor(0xFF4D0418);
                else
                    vi.setBackgroundColor(0xFF7B0326);
            }
            else
                holder=(ViewHolder)vi.getTag();

            holder.locationName.setText(data[position][1]);          

            vi.setId(Integer.parseInt(data[position][0]));

            return vi;
        }

        class ViewHolder {
            TextView locationName;
        }
    }

这里是这些项目的xml(地点项目xml)。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center_vertical">
    <ImageView
        android:id="@+id/centerbullet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="3dip"
        android:src="@drawable/centerbullet"/>
    <TextView android:id="@+id/locationName" 
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:textStyle="bold"
        android:paddingLeft="10dip"
        android:text="hello hello egele efsdffgxnd"
        android:textSize="15dip" />
</LinearLayout>

现在,我的问题是清单和项目,只需要展示起码的宽度,而我要说,清单是完全可用的。 我的法典有什么问题?

最佳回答

和roid:在清单中,延迟-重量=”1 解决了这一问题。

问题回答

使用风格

style="?android:attr/spinnerItemStyle"




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签