I have a view (scalesView.java) that I create with onDraw and I need
to add a spinner selector to the lower left of the screen. The code
(below) runs and places a spinner where I need it but when I enable
the setAdapter, the app crashes. When I remove the spinner code the
view works fine, when I add a listview (instead of a spinner) it works
fine. Although I can't get the listview small enough to work in the
corner of my app.

What am I missing about using setAdapter?

        @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mView = new scalesView(this);


        scaleSpin = (Spinner)this.findViewById(R.id.scalespinner);

       ArrayAdapter<String> adapter = new
ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, res);
       System.out.println("first");
 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        System.out.println("second");

//This line crashes the app
        //scaleSpin.setAdapter(adapter);



        final RelativeLayout myLayout = new RelativeLayout(this);
        myLayout.setLayoutParams(new
RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));

        View v = this.getLayoutInflater().inflate(R.layout.scalelist,
null);
        RelativeLayout.LayoutParams params2 = new
RelativeLayout.LayoutParams(100, LayoutParams.WRAP_CONTENT);
        params2.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        params2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        v.setLayoutParams(params2);


        myLayout.addView(mView);
        myLayout.addView(v);


        setContentView(myLayout);

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to