Error while using setDisplayHomeAsUpEnabled in FadingActionBarHelper - android

I want to implement FadingActionBar in my application to get the effects like latest Google play Music app.
Below is how i am using the FadingActionBar
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FadingActionBarHelper helper = new FadingActionBarHelper()
.actionBarBackground(R.drawable.ab_background)
.headerLayout(R.layout.header)
.contentLayout(R.layout.activity_listview);
setContentView(helper.createView(this));
helper.initActionBar(this);
Here i wanted to add back button in actionBar using setDisplayHomeAsUpEnabled(true);
I am getting error while adding the above code saying no such method found.
My question is there any way to add setDisplayHomeAsUpEnabled(true);
if not, how we can add back button for FadingActionBar

i had the same problem but it was because i was using appcompat v7 so you just have to add this.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Or
getActionBar().setDisplayHomeAsUpEnabled(true);
Hope it helps

Related

How to code google analytics for mobile apps?

I'm new to android programming and I assume that I've completely prepared my app to use google-analytics including setting up the necessary plugins, dependencies, configurations , etc... according to this.
but for coding my activities I'm quite confused and i couldn't find straightforward instructions to code my activities in order to use the minimum features of google analytics (like merely knowing the number of page visits and user counts).thank you in advance!
the answer was quite simple.. all i needed was modifying the oncreate method like below:
public class MainActivity extends AppCompatActivity {
private Tracker mTracker;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
AnalyticsApplication application = (AnalyticsApplication) getApplication();
mTracker = application.getDefaultTracker();
mTracker.setScreenName("Home");
mTracker.send(new HitBuilders.AppViewBuilder().build());
and a few adjustments in the manifest.

Can't set Logo in ActionBar

I've seriously tried everything.
I've tried both setLogo() and setIcon().
I've tried adding android:logo="" in manifest.
I've made sure to try both supportActionBar and regular ActionBar. (I'm running sdk 21 with a min sdk of 15.)
The funny thing is if I try to use the regular ActionBar I get null pointers but when I use the support ActionBar it at least works.
Is there anything else I can try...? Here's where I try and change it.
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActionBar ab = getSupportActionBar();
ab.setLogo(R.drawable.logo);
If your min sdk is 15, i'm not sure why you're using the support package at all.
You class should instead extend Activity, and use getActionBar().

Android L setEnterTransition not working

I'm currently trying to use the new transition animations in Android 5.0.
I started as suggested by many Tutorials:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
getWindow().setEnterTransition(new Explode());
getWindow().setExitTransition(new Explode());
setContentView(R.layout.activity_quiz);
getActionBar().setTitle("Java Skill");
getActionBar().setElevation(2);
}
I put this code into every activity of my project but it never works. The only animation I get is the "slide in effect" from the bottom.
Am I doing something wrong here? Do I have to define anything else, maybe in my layouts or styles.xml?
I hope anyone ran into the same problem as me. Thanks very much in advance!
The documentation may be wrong. You need to enable FEATURE_ACTIVITY_TRANSITION.

Actionbar on top of PhoneGap webview

I'm trying to add the actionbar of Android(4.0) to the webview activity of PhoneGap (2.0.0). I'm using the same actionbar in another activity in my application. It's in the menu.xml file and in the other activity everything is working without any problem.
When I load the webview, the actionbar is not shown.
I get a nullPointerExeption on the actionbar. I already have the #targetApi(14). And the resource is working for the homeactivity but not for the webviewactivity.
ActionBar actionBar = getActionBar();
actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.bar));
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setIcon(R.drawable.logo);
I found getActionBar is a function from the Activity class and this is returning null. Probably phonegap is giving a twist to the activty and therefore it is not possible to load the actionbar.
Anybody experience with this? Thanks
#Override
public void onCreate(Bundle savedInstanceState) {
super.setBooleanProperty("showTitle", true);
super.onCreate(savedInstanceState);
The setBooleanProperty before super.onCreate was the answer for the problem

How to set the mainfest.xml to remove the default label

Any one can share the mainfest.xml.
How to set it? then can remove the label..?
Thanks very much
Your question isn't very clear, but assuming you're asking about displaying the name of your application: There's a line in the < application > section that has "#string/app_name" in it, which you could remove. Not sure that's a good idea though. Alternatively you might be asking how to remove the title bar at the top of an application. If so, use
requestWindowFeature(Window.FEATURE_NO_TITLE);
If by removing the default label, you mean removing the title bar, you can use the following in your onCreate
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
}

Categories

Resources