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 ???
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