cs x cs x - 1 year ago 196
Java Question

Can Android DataBinding use inner class?


public class UpdateActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

ActivityUpdateBinding dataBinding = DataBindingUtil.setContentView(this, R.layout.activity_update);

interface Listener {
void onClick(View v);



if i set the 'listener',it always Errors.it is mean i can't set inner class,or i should set 'listener' on other way?

Answer Source

You can access inner classes using Android's data binding library as long as the inner class is declared public. I was able to use an inner class by making sure it was public. Instead of using com.kycq.reader.UpdateActivity$Listener use com.kycq.reader.UpdateActivity.Listener to access the inner class.