开发者

How to create a layout like Android CallLog's layout

开发者 https://www.devze.com 2023-02-04 07:01 出处:网络
Hey I want to create a layout like this for my application. Of course the functionalities will be differents. I\'m studying the source code for this, and I found the xml files that does that. I just d

Hey I want to create a layout like this for my application. Of course the functionalities will be differents. I'm studying the source code for this, and I found the xml files that does that. I just dont know how to implement that in the activity, how to call, what to create, a listview, etc.

How to create a layout like Android CallLog's layout

I mean, I just want to list the name with a bigger font and the date like in the image, with a small font but aligned to the right.

Because, I want to get the data from the database I've created and print it like this list of CallLog.

I mean, how Android makes the date with that icon align in the right, with a small font size?

So this is my activity, I just dont know what xml file from the source code to use, or what method to implement so I can print the data like the image example.

   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(),
                    ((TextV开发者_运维问答iew) view).getText(), Toast.LENGTH_LONG).show();
        }
    });

}

 }

Thanks.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消