I'm building my own android application and when i put it on in my Nexus 5 and Xperia Neo works fine, but on Nexus 4 or Galaxy S3 works slowly. I don't know what its happend. Could you help me? I'm working with android:minSdkVersion="14" and android:targetSdkVersion="17", Fragments and one DrawerLayout.
package test.Droidlogin;
import android.content.res.Configuration;
import 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;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
public class Herramientas extends FragmentActivity {
String user;
int iduser;
TextView txt_usr, logoff, txt_iduser;
Button bmiscervezas, bbd, btools, bcrear;
ActionBarDrawerToggle toggle;
String tituloSeccion;
ListView drawer;
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);
}
}