如何创建像Android CallLog';s布局
嘿,我想为我的应用程序创建这样的布局。当然,功能会有所不同。我正在研究这方面的源代码,并找到了实现这一点的xml文件。我只是不知道如何在活动中实现,如何调用,创建什么,列表视图等等 我的意思是,我只想列出一个大字体的名字和日期,就像图中一样,用一个小字体,但向右对齐 因为,我想从我创建的数据库中获取数据,然后像下面的调用日志列表一样打印出来 我的意思是,安卓如何让日期与右边的图标对齐,并使用小字体 这就是我的活动,我只是不知道源代码中要使用什么xml文件,或者要实现什么方法,以便像图像示例那样打印数据如何创建像Android CallLog';s布局,android,android-layout,android-source,Android,Android Layout,Android Source,嘿,我想为我的应用程序创建这样的布局。当然,功能会有所不同。我正在研究这方面的源代码,并找到了实现这一点的xml文件。我只是不知道如何在活动中实现,如何调用,创建什么,列表视图等等 我的意思是,我只想列出一个大字体的名字和日期,就像图中一样,用一个小字体,但向右对齐 因为,我想从我创建的数据库中获取数据,然后像下面的调用日志列表一样打印出来 我的意思是,安卓如何让日期与右边的图标对齐,并使用小字体 这就是我的活动,我只是不知道源代码中要使用什么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();
}
});
}
}
公共类RatedCalls扩展了ListActivity{
私有静态最终字符串日志\u TAG=“RatedCalls”;
专用表格;
私人呼叫数据助手cdh;
私人桌排;
私人桌子第2排;
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.recent_调用);
i(Log_标记,“从onCreate()调用”);
cdh=新的CallDataHelper(此);
startService(新意图(这个,RatedCallsService.class));
Log.i(Log_标签,“调用服务”);
Log.i(Log_标签,“呼叫前填充列表”);
/*
*mAdapter=new-RecentCallsAdapter();
*getListView().setOnCreateContextMenuListener(此);
*setListAdapter(mAdapter);
*/
填充列表();
Log.i(Log_标签,“呼叫后填充列表”);
}
恢复时公开作废(){
super.onResume();
填充列表();
}
公共无效填充列表(){
Log.i(Log_标签,“输入到填充列表中”);
List ratedCalls=new ArrayList();
ratedCalls=this.cdh.selectTopCalls();
//setListAdapter(新的ArrayAdapter)(此,R.layout.recent_调用_列表_项,
//差饷租值);;
ListView lv=getListView();
lv.setTextFilterEnabled(真);
getListView().setOnCreateContextMenuListener(此);
lv.setOnItemClickListener(新的OnItemClickListener(){
public void onItemClick(AdapterView父级、视图、,
内部位置,长id){
Toast.makeText(getApplicationContext(),
((TextView)view.getText(),Toast.LENGTH_LONG.show();
}
});
}
}
谢谢。我将创建一个包含多个文本视图的列表视图。这只是一个两步过程:
你在问如何为你编写一个庞大的程序。一步一步地把它分解。没有人会为你编写代码。不,不是这样,我只是想得到帮助,如果你告诉我该怎么做,或者是一些如何实现的教程,没关系。谢谢。首先学习如何制作一个简单的列表,然后也许我们可以帮你做一些类似的事情。我不知道从哪里开始告诉你你需要做什么我知道如何实现listView。你可以从你认为最好的方式开始。谢谢