2011-01-13 131 views
0

嘿,我想为我的应用程序创建一个这样的布局。当然,这些功能将是不同的。我正在研究这个源代码,并且我找到了这样做的xml文件。我只是不知道如何实现,在活动中,如何调用,创造什么,列表视图等如何创建一个像Android CallLog布局的布局

alt text

我的意思,我只是想用一个更大的字体和列表的名称像图像中的日期,具有小字体但与右侧对齐。

因为我想从我创建的数据库中获取数据,并像列表中的CallLog那样打印它。

我的意思是,Android如何使该图标的日期与右侧对齐,并且字体很小?

所以这是我的活动,我只是不知道从源代码使用什么XML文件,或实现什么方法,所以我可以打印像图像示例的数据。

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(); 
     } 
    }); 

} 

} 

谢谢。

+1

你在问如何为你编写一个庞大的程序。一步一步分解它。没有人会为你编写代码。 – Falmarri 2011-01-13 18:01:49

回答

0

这只是一个两个步骤:

  1. 创建代表您的清单1个项目布局文件。
  2. 扩展数组适配器并在那里使用您的自定义布局文件。互联网上有几个关于如何扩展阵列适配器的例子。
0

我将创建一个包含多个textview的listview。