我有一个包含按钮的自定义导航栏,我会调度点击事件,以便包含我的导航栏的活动可以响应点击
public class BarrePersonnalisee extends LinearLayout implements OnClickListener {
Context mycontext;
View convertview;
ImageButton searchadresse;
public BarrePersonnalisee(Context context, AttributeSet attrs) {
super(context, attrs);
mycontext=context;
convertview=LayoutInflater.from(mycontext).inflate(R.layout.barre, this);
searchadresse=(ImageButton)convertview.findViewById(R.id.searchadresse);
searchadresse.setOnClickListener(this);
}
public void onClick(View arg0) {
switch (arg0.getId()) {
case R.id.searchadresse:
//I want to dispatch this event
break;
}
}
....
}
public class TaxiMapActivity extends MapActivity{
BarrePersonnalisee barre;
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
barre=(BarrePersonnalisee)this.findViewById(R.id.barre1);
//task to do here
}
谁能帮忙?