开发者

problem with android simple drop down list

I have an app in android which uses an autocomplete for a query in the DB....The autocomplete entries are displayed in a drop down list ....

The problem is that the size of the text displayed in this drop down list is very big and don't know how to make it smaller:

This is a piece of code:

    public View newView(Context context, Cursor cursor, ViewGroup parent){

        Cursor c = getCursor();
        final LinearLayout ret = new LinearLayout(context);

        final LayoutInflater inflater = LayoutInflater.from(context);
        mName = (TextView) inflater.inflate(开发者_如何转开发
                android.R.layout.simple_dropdown_item_1line, parent, false);


        mNumber = (TextView) inflater.inflate(
                android.R.layout.simple_dropdown_item_1line, parent, false);

        ret.setOrientation(LinearLayout.HORIZONTAL);

        LinearLayout horizontal = new LinearLayout(context);
        horizontal.setOrientation(LinearLayout.HORIZONTAL);

        int nameCol = c.getColumnIndex(db.KEY_SURSA);

        String name = c.getString(nameCol);

        String number = c.getString(c.getColumnIndex(db.KEY_DATE));

        mName.setText(name);
        mNumber.setText(number);

        horizontal.addView(mName, new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        ret.addView(mNumber, new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        ret.addView(horizontal, new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        return ret;

    }

mName and mNumber are the text view used for displaying my DB content....but how I obtain them frm inflating android.R.layout.simple_dropdown_item_1line I don't know how could I modify the text size...


Maybe this is what you are looking for? This would set the text size to 100dip, you could adjust the number to whatever you are looking for.

mName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 100);


I think you can use the singleLine attribute in the xml of each text view with declaring the drop down adapter to be custom.

<TextView
        android:id="@+id/info"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textColor="black"
        android:text="bla bla bla bla bla bla"
        android:singleLine="true" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜