我正在构建我自己的Android应用程序,当我把它放在我的Nexus 5和Xperia Neo上工作正常,但在Nexus 4或Galaxy S3上运行缓慢。我不知道它发生了什么。你可以帮帮我吗? 我正在使用android:minSdkVersion =“14”和android:targetSdkVersion =“17”,Fragments和一个DrawerLayout。
包test.Droidlogin;
import android.content.res.Configuration;
导入android.os.Bundle;
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.DrawerLayout;
import android.view.MenuItem;
导入android.view.View;
导入android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
导入android.widget.Button;
import android.widget.ListView;
导入android.widget.TextView;
公共类Herramientas扩展了FragmentActivity {
String user;
int iduser;
TextView txt_usr,logoff,txt_iduser;
按钮bmiscervezas,bbd,btools,bcrear;
ActionBarDrawerToggle toggle;
String tituloSeccion;
ListView抽屉;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.herramientas);
drawer = (ListView) findViewById(R.id.drawer);
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
final String[] opciones = {"CONVERSORES", "Temperatura", "Densidad", "Peso", "Volumen", "Presión", "ESPECÍFICAS", "Corrección de Densímetro", "Infusion Step Tool", "Atenuación y Alcohol",
"Mash Adjust", "Weight to Volume", "Refractometer", "Carbonation"};
drawer.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, opciones));
drawer.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
android.support.v4.app.Fragment fragment = null;
switch (position) {
case 1:
fragment = new HTemperatura();
break;
case 2:
fragment = new HDensidad();
break;
case 3:
fragment = new HPeso();
break;
case 4:
fragment = new HVolumen();
break;
case 5:
fragment = new HPresion();
break;
case 7:
fragment = new HCorreccionDensimetro();
break;
case 8:
fragment = new HInfusionStepTool();
break;
case 9:
fragment = new HAtenuacionyAlcohol();
break;
case 10:
fragment = new HMashAdjust();
break;
case 11:
fragment = new HWeighttoVolume();
break;
case 12:
fragment = new HRefractometer();
break;
case 13:
fragment = new HCarbonation();
break;
}
if(position != 0 && position != 6){
android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.content_frame, fragment)
.commit();
drawer.setItemChecked(position, true);
tituloSeccion = opciones[position];
getActionBar().setTitle(tituloSeccion);
drawerLayout.closeDrawer(drawer);
}
}
});
//////
toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer_aux, R.string.app_name, R.string.hello_world ){
public void onDrawerClosed(View view) {
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle("Menú");
invalidateOptionsMenu();
}
};
drawerLayout.setDrawerListener(toggle);
//getActionBar().setIcon(R.drawable.ic_drawer_aux);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setDisplayShowTitleEnabled(true);
getActionBar().setHomeButtonEnabled(true);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
toggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
toggle.onConfigurationChanged(newConfig);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (toggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
答案 0 :(得分:0)
<style name="AppBaseTheme" parent="android:Theme.Holo">
</style>
到此:
<style name="AppBaseTheme" parent="android:Theme.Holo">
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@null</item>
</style>
现在我可以将每个layout.xml放在我的背景上。但我的问题是,在我改变之前,我的按钮看起来像一个“真正的按钮”,但现在新的更改看起来像没有边框的TextView。