1、一个fragment1类,代码如下:
public static final int PAGE_SIX=5;
public void onClick(View v) {
switch (v.getId()) {
case R.id.ib_update: //点击到该按钮时
mButtonInterface.onButtonSelect( PAGE_SIX); //调用下面的接口进行传值
break;
}
}
//定义一个接口
private buttonSelectInterface mButtonInterface;
public interface buttonSelectInterface {
public void onButtonSelect(int button);
}
2、mainActivity类中继承buttonSelectInterface:
//传递过来的参数
@Override
public void onButtonSelect(int button) {
switch(button){
case PAGE_SIX:
vpager.setCurrentItem(PAGE_SIX);
break;
}
}
跪求大神!!!
问题:调试发现点击按钮时,可以看到一个fragment1类中的值是5(由于接口不能设置断点,没看到在fragment1类中的接口botton的值,红色部分),但是在mainActivity类中,botton的值是没有的。也就是说fragment1类中
接口的值没有传到mainactivity过来。
public static final int PAGE_SIX=5;
public void onClick(View v) {
switch (v.getId()) {
case R.id.ib_update: //点击到该按钮时
mButtonInterface.onButtonSelect( PAGE_SIX); //调用下面的接口进行传值
break;
}
}
//定义一个接口
private buttonSelectInterface mButtonInterface;
public interface buttonSelectInterface {
public void onButtonSelect(int button);
}
2、mainActivity类中继承buttonSelectInterface:
//传递过来的参数
@Override
public void onButtonSelect(int button) {
switch(button){
case PAGE_SIX:
vpager.setCurrentItem(PAGE_SIX);
break;
}
}
跪求大神!!!
问题:调试发现点击按钮时,可以看到一个fragment1类中的值是5(由于接口不能设置断点,没看到在fragment1类中的接口botton的值,红色部分),但是在mainActivity类中,botton的值是没有的。也就是说fragment1类中
接口的值没有传到mainactivity过来。