该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
用Eclipse开发的APP,其中一个Activit的标题栏没有显示,但没对Activity做过任何配置。由于不知道哪里出问题,下面把Activity的java文件、布局文件和Mainfest全部放出来
======================
Activity.java
------------------
package com.example.RemoteControl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;
public class AreasSettingActivity extends Activity implements OnClickListener {
ListView lsvAreas;
Button btnAdd;
Button btnEdit;
Button btnRefresh;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_areas_setting);
lsvAreas = (ListView) findViewById(R.id.lsvAreas);
btnAdd = (Button) findViewById(R.id.btnAdd);
btnEdit = (Button) findViewById(R.id.btnEdit);
btnRefresh = (Button) findViewById(R.id.btnRefresh);
btnAdd.setOnClickListener(this);
btnEdit.setOnClickListener(this);
btnRefresh.setOnClickListener(this);
lsvAreas.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
ListView list = (ListView) parent;
@SuppressWarnings("unchecked")
String area = (String) list.getItemAtPosition(position);
Intent intent = new Intent();
intent.setClass(AreasSettingActivity.this,
EquitmentsControlActivity.class);
intent.putExtra("area", area);
startActivity(intent);
}
});
refresh();
}
private List getAreasData(Cursor cursor) {
List list = new ArrayList();
list.add("全部设备");
while (cursor.moveToNext()) {
list.add(cursor.getString(cursor.getColumnIndex("area")));
}
return list;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.btnAdd:
// Intent intent = new Intent();
// intent.setClass(EquitmentsControlActivity.this,
// EquitmentAddActivity.class);
// startActivity(intent);
break;
case R.id.btnEdit:
break;
case R.id.btnRefresh:
refresh();
break;
}
}
private void refresh() {
// TODO Auto-generated method stub
Cursor cursor = EquitmentsAccess.queryEquitmentsByColumnName("area",
true);
lsvAreas.setAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, getAreasData(cursor)));
}
}
===============================
=
=
=================================
布局文件
-----------------------
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.RemoteControl.EquitmentControlActivity" >
android:id="@+id/lsvAreas"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="12" >
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
style="?android:attr/buttonBarStyle" >
android:id="@+id/btnAdd"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/strAdd"
style="?android:attr/buttonBarButtonStyle" >
android:id="@+id/btnEdit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/strEdit"
style="?android:attr/buttonBarButtonStyle" >
android:id="@+id/btnRefresh"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/strRefresh"
style="?android:attr/buttonBarButtonStyle" >
==================================
=================================
Mainfest文件
-------------------------------
package="com.example.RemoteControl"
android:versionCode="1"
android:versionName="1.0" >
android:minSdkVersion="14"
android:targetSdkVersion="21" />
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name=".LoginActivity"
android:label="@string/app_name" >
android:name=".MainActivity"
android:label="@string/title_activity_main" >
android:name=".EquitmentsControlActivity"
android:label="@string/title_activity_equitment_control" >
android:name=".EquitmentAddActivity"
android:label="@string/title_activity_add_equitment" >
android:name=".EquitmentConfigActivity"
android:label="@string/title_activity_equitment_config" >
android:name=".AreasSettingActivity"
android:label="@string/title_activity_areas_setting">
===============================