目前它只显示应用程序的名称,我希望它显示自定义的内容,并在我的应用程序中为每个屏幕显示不同的内容.
例如:我的主屏幕可以在操作栏中显示"page1",而应用切换到的另一个活动可以在该屏幕操作栏中显示"page2".
在我的应用程序屏幕中,我想将标题显示为水平中心.我试过下面的布局xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Connections" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢
我发现无法将文本集中在listview中,尝试使用wrap_content和layout_gravity = center几乎所有文本都不会移动
这是我的班级agenceEco
package com.blabla;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.*;
public class agenceEco extends Activity {
ListView myList;
String[] listContent = {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.agence);
myList = (ListView)findViewById(R.id.liste_agences);
ArrayAdapter<String> adapter
= new ArrayAdapter<String>(this,
R.layout.simple_list_item,
listContent);
myList.setAdapter(adapter);
myList.setOnItemClickListener(new AdapterView.OnItemClickListener() { …Run Code Online (Sandbox Code Playgroud)