Reputation: 712
I am in the contentview of seekbarlist.xml and need to get the layout of seekbars.xml. I need to send the layout to CustomSeekBar constructor. Below, you can see that I tried to set the content view to one layout, grab it, then switch to the other. This will not work b/c I have to extend listactivity and the layout must have an item with the id "list". seekbars.xml does not have a "list" and it would not make sense for it to have it. How can I get the layout of seekbars?
public class ColorsActivity extends ListActivity {
/** Called when the activity is first created. */
//Array Adapter that will hold our ArrayList and display the items on the ListView
SeekBarAdaptor seekBarAdaptor;
//List that will host our items and allow us to modify that array adapter
ArrayList<CustomSeekBar> seekBarArrayList=null;
// TextView myValueText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.seekbars);
LinearLayout myLayout = (LinearLayout)findViewById(R.layout.seekbars);
setContentView(R.layout.seekbarlist);
//Initialize ListView
ListView lstTest= getListView();
//Initialize our ArrayList
seekBarArrayList = new ArrayList<CustomSeekBar>();
//Initialize our array adapter
seekBarAdaptor = new SeekBarAdaptor(ColorsActivity.this, R.layout.seekbars, seekBarArrayList);
CustomSeekBar red = new CustomSeekBar(this, myLayout, "red", 1);
//CustomSeekBar blue = new CustomSeekBar(this, "blue");
//CustomSeekBar green = new CustomSeekBar(this, "green");
//Set the above adapter as the adapter of choice for our list
lstTest.setAdapter(seekBarAdaptor);
seekBarArrayList.add(red);
//seekBarArrayList.add(blue);
//seekBarArrayList.add(green);
Amarino.connect(this, "00:11:11:21:05:53");
}
}
Upvotes: 0
Views: 2580
Reputation: 13552
You need to use LayoutInflator.
LayoutInflater.from(this).inflate(R.layout.seekbars, null);
You can pass null to the ViewGroup parameter.
Read up some more on LayoutInflator here http://developer.android.com/reference/android/view/LayoutInflater.html
Upvotes: 3