一.效果图
二.布局文件
activity_main.xml布局中
left_item.xml布局中
在right_item.xml布局中
在rigth_item_child.xml
在MainActivity.java中
public class MainActivity extends AppCompatActivity implements ILeftview, IRightview {
private RecyclerView left_recycler;
private RecyclerView right_recycler;
private LeftPresenter leftPresenter;
private RightPresenter rightPresenter;
private LeftAdapter leftAdapter;
private RightAdapter rightAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//初始化控件
init();
leftPresenter.showLeft();
rightPresenter.showRight(1);
}
private void init() {
left_recycler = (RecyclerView) findViewById(R.id.left_recycler);
right_recycler = (RecyclerView) findViewById(R.id.right_recycler);
leftPresenter = new LeftPresenter(this);
rightPresenter = new RightPresenter(this);
}
@Override
public void successLf(final Listresult) {
runOnUiThread(new Runnable() {
@Override
public void run() {
leftAdapter = new LeftAdapter(MainActivity.this);
//布局
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
left_recycler.setLayoutManager(linearLayoutManager);
left_recycler.setAdapter(leftAdapter);
result.get(0).setClick(true);//默认第一个选中