SHARE
TWEET

RecycleView

cendolinside Nov 15th, 2017 (edited) 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.test.api.api.Activity;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.content.SharedPreferences;
  6. import android.os.Bundle;
  7. import android.support.v7.app.AppCompatActivity;
  8. import android.support.v7.widget.LinearLayoutManager;
  9. import android.support.v7.widget.RecyclerView;
  10. import android.view.View;
  11.  
  12. import com.test.api.api.Controller.Akun_Get;
  13. import com.test.api.api.GetSet.tblAkunDatabase;
  14. import com.test.api.api.R;
  15.  
  16. import java.util.List;
  17.  
  18. public class Categories extends AppCompatActivity {
  19.  
  20.     private RecyclerView mRecyclerView;
  21.     private RecyclerView.Adapter mAdapter;
  22.     private RecyclerView.LayoutManager mLayoutManager;
  23.    
  24.     private final Akun_Get AllAkun;
  25.     public List<tblAkunDatabase> result;
  26.     public String data;
  27.    
  28.  
  29.  
  30.     public Categories()
  31.     {
  32.         AllAkun = new Akun_Get();
  33.     }
  34.  
  35.     @Override
  36.     protected void onCreate(Bundle savedInstanceState) {
  37.         super.onCreate(savedInstanceState);
  38.         setContentView(R.layout.activity_categories);
  39.         mRecyclerView = (RecyclerView) findViewById(R.id.recyclerViewCategory);
  40.         mLayoutManager = new LinearLayoutManager(this);
  41.         mRecyclerView.setLayoutManager(mLayoutManager);
  42.  
  43.         loadData();
  44.  
  45.     }
  46.  
  47.     public void loadData()
  48.     {
  49.         SharedPreferences prefs = getSharedPreferences("SESSION", Context.MODE_PRIVATE);
  50.         data = prefs.getString("ID","kosong");
  51.         AllAkun.getAkunUser(data, new Akun_Get.dataCallBack() {
  52.             @Override
  53.             public void getData(List<tblAkunDatabase> value) {
  54.                 result = value;
  55.                 //mRecyclerView = (RecyclerView) findViewById(R.id.recyclerViewCategory);
  56.                 mAdapter = new AkunAdaptor(result);
  57.                 //mLayoutManager = new LinearLayoutManager(getApplicationContext());
  58.                 //mRecyclerView.setLayoutManager(mLayoutManager);
  59.                 //mRecyclerView.setItemAnimator(new DefaultItemAnimator());
  60.                 mRecyclerView.setAdapter(mAdapter);
  61.  
  62.             }
  63.         });
  64.     }
  65.  
  66.     public void categoryAdd(View v)
  67.     {
  68.         Intent inputCategory = new Intent(Categories.this,InputCategory.class);
  69.         startActivity(inputCategory);
  70.     }
  71.  
  72. }
RAW Paste Data
Top