I'm creating a custom component for an Android App (exactly a volume fader for an audio mixer). It works fine.
What I want is to load several instances of this component at Run-Time. I tried with this:
LinearLayout layout = (LinearLayout)findViewById(R.id.mixerContainer) //This layout
for(int i=0;i<8;i++){
LayoutInflater l = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = l.inflate(R.Layout.MyVolumeFader, null);
layout.add(v);
}
This adds the view correctly, but doesn't attach all the logic of my component (that is contained in MyVolumeFader class).
How can I solve this problem?
--
The code looks like:
MyVolumeFader.java
public class MyVolumeFader extends RelativeLayout{
[...]
private VerticalSeekBar volumeBar;
[...]
->volumeBar handling<-
}
MyVolumeFader.xml
<RelativeLayout...
Some TextViews, Buttons and a VerticalSeekBar are here...
Thank you.