MyTetra Share
Делитесь знаниями!
MainActivity.java
22.04.2017
11:24
Раздел: Android - Ресурсы - developer.android.com - API Guides - Создание списков и карточек
MainActivity.java

MainActivity.java

package com.example.rt.recycler; 
 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.support.v7.widget.LinearLayoutManager; 
import android.support.v7.widget.RecyclerView; 
 
 
public class MainActivity extends AppCompatActivity { 
    private RecyclerView mRecyclerView; 
    private RecyclerView.Adapter mAdapter; 
    private RecyclerView.LayoutManager mLayoutManager; 
 
    private String[] myDataset = {"abc", "cba", "cyeryba", "cbyrewsya", "cbfhdha", "cbzfhza", "czdfhzdba"}; 
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.recyclerview); 
        mRecyclerView = (RecyclerView) findViewById(R.id.rv); 
 
        // use this setting to improve performance if you know that changes 
        // in content do not change the layout size of the RecyclerView 
        mRecyclerView.setHasFixedSize(true); 
 
        // use a linear layout manager 
        mLayoutManager = new LinearLayoutManager(this); 
        mRecyclerView.setLayoutManager(mLayoutManager); 
 
        // specify an adapter (see also next example) 
        mAdapter = new MyAdapter(myDataset); 
        mRecyclerView.setAdapter(mAdapter); 
    } 
 
}
 
MyTetra Share v.0.52
Яндекс индекс цитирования