Monday, September 23, 2013

[android help] android development using action with icons and text beside the icons


android development using action with icons and text beside the icons



i am creating action bar with icons and text the action bar work as it should but the problem is that the text do not beside the icon how to fix this problem


i want always to make the icons and texts displayed on the screen can anyone help me ???






android:id="@+id/action_settings"
android:icon="@drawable/ic_launcher"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/action_settings"/>
android:id="@+id/action_setting2"
android:icon="@drawable/ic_launcher"
android:orderInCategory="100"
android:showAsAction="ifRoom"
android:title="@string/app_name"/>






package com.action_bar_test;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
Toast.makeText(this, "Menu Item 1 selected", Toast.LENGTH_SHORT)
.show();
break;
case R.id.action_setting2:
Toast.makeText(this, "Menu item 2 selected", Toast.LENGTH_SHORT)
.show();
break;

default:
break;
}

return true;
}
}


Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...