Ive been trying to load data to a listview on an android app
This is my activity that will load the listview:
public class DetallesCliente extends ActionBarActivity {
String[] data = {"S","D","A"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detalles_cliente);
ListView lista = (ListView)findViewById(R.id.listaDetalles);
ArrayAdapter<String> adaptador = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.list_content, data);
try{lista.setAdapter(adaptador);}
catch (Exception e){Log.i("WS", e.toString());}
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
ok, now this is the code in the fragment of this activity
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.facturas.DetallesCliente$PlaceholderFragment" >
<ListView
android:id="@+id/listaDetalles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="27dp" >
</ListView>
<TextView
android:id="@+id/tvDetalles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:text="Detalles del Cliente"
android:textAppearance="?android:attr/textAppearanceMedium" />
the problem is when i try to load the data it is throwing me a null pointer exception, i have no fragment class cause i dont understand them, i tried to modify text from a textview and it didnt work neither
what is the correct way to allow the listview to be edited