Pregunta

Hola Quiero crear un diseño como este para mi aplicación. Por supuesto las funcionalidades serán differentes. Estoy estudiando el código fuente para esto, y me encontré con los archivos XML que eso. Yo sé simplemente no cómo implementar que en la actividad, cómo llamar, lo que a crear, una vista de lista, etc.

text alt

Es decir, sólo quiero a la lista el nombre de un tipo de letra más grande y la fecha como en la imagen, con una fuente pequeña, pero alineado a la derecha.

Porque, quiero obtener los datos de la base de datos que he creado e imprimirlo como esta lista de CallLog.

Es decir, ¿Android hace que la fecha con ese icono de alineación en la derecha, con un tamaño de letra pequeño?

Así que este es mi actividad, sólo sé lo Dont archivo XML desde el código fuente para su uso, o qué método para poner en práctica para que pueda imprimir los datos como el ejemplo de la imagen.

   public class RatedCalls extends ListActivity {

private static final String LOG_TAG = "RatedCalls";
private TableLayout table;
private CallDataHelper cdh;
private TableRow row;
private TableRow row2;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.recent_calls);

    Log.i(LOG_TAG, "calling from onCreate()");

    cdh = new CallDataHelper(this);

    startService(new Intent(this, RatedCallsService.class));
    Log.i(LOG_TAG, "Service called.");
    Log.i(LOG_TAG, "before call fillList");

    /*
     * mAdapter = new RecentCallsAdapter();
     * getListView().setOnCreateContextMenuListener(this);
     * setListAdapter(mAdapter);
     */

    fillList();
    Log.i(LOG_TAG, "after call fillList");

}

public void onResume() {

    super.onResume();
    fillList();

}

public void fillList() {

    Log.i(LOG_TAG, "entered on fillList");
    List<String> ratedCalls = new ArrayList<String>();
    ratedCalls = this.cdh.selectTopCalls();


     //setListAdapter(new ArrayAdapter<String>(this, R.layout.recent_calls_list_item,
     //ratedCalls));


    ListView lv = getListView();
    lv.setTextFilterEnabled(true);
    getListView().setOnCreateContextMenuListener(this);

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {


            Toast.makeText(getApplicationContext(),
                    ((TextView) view).getText(), Toast.LENGTH_LONG).show();
        }
    });

}

 }

Gracias.

¿Fue útil?

Solución

It's just a 2 step process:

  1. Create a Layout Xml file which represents 1 item of your list.
  2. Extend Array Adapter and use your custom layout file there. There are several examples on the internet on how to extend Array Adapter.

Otros consejos

I'm going to create a listview with multiple textviews.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top