Skip to content

Instantly share code, notes, and snippets.

@kundansviet
Created February 21, 2016 13:00
Show Gist options
  • Save kundansviet/3533a5cca5f4176c42e1 to your computer and use it in GitHub Desktop.
Save kundansviet/3533a5cca5f4176c42e1 to your computer and use it in GitHub Desktop.
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public class UserDetailList extends AppCompatActivity implements Listener {
RecyclerView recyclerView;
DbHelper dbHelper;
ListAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_detail_list);
dbHelper = DbHelper.getInstance(getApplicationContext());
recyclerView = (RecyclerView) findViewById(R.id.rv_contactlist);
adapter = new ListAdapter(this, dbHelper.getAllUser());
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
@Override
public void nameToChnge(String name) {
dbHelper.deleteRow(name);
adapter = new ListAdapter(this, dbHelper.getAllUser());
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment