|
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.example.myapplication7.R;
import com.example.myapplication7.adapter.MyAdapter;
import com.example.myapplication7.bean.Bean;
import com.example.myapplication7.iview.IMActivity;
import com.example.myapplication7.presenter.Presenter;
import com.example.myapplication7.utils.Api;
import java.util.List;
public class MainActivity extends AppCompatActivity implements IMActivity {
String key = "71e58b5b2f930eaf1f937407acde08fe";
String num = "10";
private RecyclerView recyclerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
recyclerView = findViewById( R.id.recycler );
recyclerView.setLayoutManager( new LinearLayoutManager( this ) );
Presenter presenter = new Presenter( this );
presenter.getUrl( Api.Url, key, num );
}
@Override
public void news(Bean bean) {
List<Bean.NewslistBean> newslist = bean.getNewslist();
MyAdapter adapter = new MyAdapter( MainActivity.this, newslist );
recyclerView.setAdapter( adapter );
}
}
|
|