Generating a RelativeLayout in Java

by Fr盲ntz Miccoli » Thu, 26 Jun 2008 15:04:57 GMT


Sponsored Links
 Can someone please give me an example of an implentation of a custom view
extending a relative layout and not using XML.

For exemple the builder of mine with absolutelayout :

    public VideoListRowView(Context context,int position) {
        super(context);

        //WARNING YOU MUST DEFINE EACH ATTRIBUTE NEEDED FOR THE CHOOSEN
LAYOUT
        //ATTENTION DEFINIR IMPERATIVEMENT TOUT LES ATTRIBUTS OBLIGATOIRES
DU LAYOUT CHOISI
        setLayoutParams(new
AbsoluteLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT, 0, 0));
        this.setPadding(paddingLeft, paddingTop, paddingRight,
paddingBottom);

        mTitle = new TextView(context);
        mTitle.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        mTitle.setMaxLines(1);
        addView(mTitle, new AbsoluteLayout.LayoutParams(
                maxWidth - thumbailWidth,
LayoutParams.WRAP_CONTENT,xTitle,yTitle));
        mTitle.setPadding(0, 0, titlePaddingRight, 0);

        mSumup = new TextView(context);
        mSumup.setMaxLines(3);
        mSumup.setHorizontallyScrolling(false);
        addView(mSumup, new AbsoluteLayout.LayoutParams(
                maxWidth - thumbailWidth,
LayoutParams.WRAP_CONTENT,xSumup,ySumup);

    }

My problem is to defined through Java the same behavior than you have when
you use the android:layout_toRight and android:below attribute

Thanks !

-- 
Frntz Miccoli
06.70.92.76.16
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. GPS glitch, reboot required

I've noticed that occasionally my GPS goes out on my G1, and will not
resolve to a location.  The cell tower location still works, but the
actual GPS does not.  To fix the problem, I have to entirely reboot my
phone.  Does anyone else have this problem, and does anyone know why
this is happening?
--~--~---------~--~----~------------~-------~--~----~

2. Student Developer Deals

Does anyone know whether there are special deals on developer phones
available for students interested in developing an Android app for a
class project?

--~--~---------~--~----~------------~-------~--~----~

3. How to add new font to android browse ?

4. Help testing on G1

5. Android on Eclipse Error

6. How to reference another GUI xml from within a GUI xml?

7. AlertDialog OnKeyListener - How to get Focused Item?