I am new to Android and I copied a sample code from web and build my app on that sample code. But I am trying to delete the image on the top toolbar. I cannot locate where the program puts that image.
here is the screen. I put a red mark on the toolbar I am talking about and I want to remove that smily face on that bar. but I dont want to delete the image, I want to find the code which puts that face there.
That will be located in your manifest file under the <application> tag. Here is an example:
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
Now each of the ="#somewhere/name" is a pointer. The icon is under res/drawable, while the other two will be under res/values/
You can use the following code. You must add in the onCreate() method of your activty :
getActionBar().setDisplayShowHomeEnabled(false);
Related
I don't know what I've done, but after I restart the Android Studio and when i run the app, it just shows only black screen when I'm calling new activity from previous activity.
The app is running good before I restarted the Android Studio.
I don't find where the wrong code is. There is no error based on the IDE.
I have this in onCreate
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
I have launched the activity by this code:
context.startActivity(new Intent(context, homeActivity.class));
in the previous class
I've seen many answers here, but do not solved my problem.
EDIT
Screenshot after calling the homeActivity
Follow CamelCase for naming conventions for Java classes check homeActivity.class --> HomeActivity.class
Ensure you define homeActivity.class in your manifest.xml
<application
android:allowBackup="true"
android:supportsRtl="true"
android:installLocation="auto"
tools:replace="android:supportsRtl"
android:icon="#mipmap/app_icon"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/AppTheme" >
// ... Other activity
<activity
android:name=".HomeActivity"
android:screenOrientation="portrait">
// ... Other meta-data & services.
</application>
Try create another activity with the same layout and class, but name it by the big letter.
I'm applying this theme from manifest :
<activity
android:name=".ui.rate.MyActivity"
android:theme="#android:style/Theme.Dialog">
</activity>
With this the application crash on setContentView() of MyActivity. If I remove it there is no crash but I need this theme
In the activity onCreate() i'm doing this :
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_rate);
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
Even if I remove the first and third lines the applicatio ncrash the same way. It's really the dialog theme that's causing the crash
How can I set it so that Android accept it ?
You can use Theme.AppCompat.Dialog as the theme of your activity to avoid
compatibility problem.
The activity will be presented as a dialog.
<activity
android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.Dialog">
</activity>
As for the title, you can use setTitle("Hola!"); to change it.
If you wanna remove the title, just call:
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
for android:theme="#style/Theme.AppCompat.Dialog",
and:
requestWindowFeature(Window.FEATURE_NO_TITLE);
for android:theme="#android:style/Theme.Dialog".
I made back button by using activity parent and getactionsupport just like this:
<activity
android:name=".News_details"
android:parentActivityName=".Main2Activity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.package.Main2Activity" />
</activity>
I also add this to my activity in the manifest.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
so what the result that I get ?
The blue arrow displays properly when I run my app in android version 4.+. When I use android version 5.+ the blue arrow reveres direction.
I use this code in manifest for hide title bar, but i cant run my application:
<activity
android:name="com.example.MainActivity"
android:theme="#android:style/Theme.NoTitleBar"
android:screenOrientation="portrait"
android:label="#string/app_name" >
Try using a physical device to test your app... Well I tried to hide the NoTitleBar but it became invisible instead!!
http://developer.android.com/tools/device.html
I would like to create android options menu (left button on android device) looking like this one:
but using onPrepareOptionsMenu creates the menu which looks like this one:
Could you please point me how to change the look of the menu? Is there anything I can set in menu XML to change it's look or maybe I should use: onPrepareContextMenu?
Thanks in advance for your reply.
Add
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
attribute to the <activity> tag in project's AndroidManifest.xml
<activity android:name="YourActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>