Git Product home page Git Product logo

Comments (9)

haidang666 avatar haidang666 commented on August 19, 2024 1

first you set theme of aboutActivity is ActionBar.
then use this code:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ........
        // add back arrow to toolbar
        if (getSupportActionBar() != null){
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onSupportNavigateUp() {
        onBackPressed();
        return true;
    }

from android-about-page.

xvolica avatar xvolica commented on August 19, 2024

I meet the same question too

from android-about-page.

medyo avatar medyo commented on August 19, 2024

Hi Guys,

Could you share with me the activity code you used

Thank you

from android-about-page.

haidang666 avatar haidang666 commented on August 19, 2024

how to add back button for this

from android-about-page.

attawit avatar attawit commented on August 19, 2024

@OverRide
public void onBackPressed() {
Intent inntent = new Intent(Intent.ACTION_MAIN);
startActivity(setIntent);
}
back press button how? please, if we are able to set onClickListener on Aboutpage , that will be helpful. I have this question also,

from android-about-page.

Eight-For-Eight avatar Eight-For-Eight commented on August 19, 2024

What does this sentence mean: "first you set theme of aboutActivity is ActionBar."? Is it "set the theme of aboutActivity to ActionBar" or is it a typo and it is "set the theme of aboutActivity in ActionBar"?
If it's the latter how do I get the theme of the aboutActivity (all I have is a working AboutPage object
and I don't see a setTheme for it).

I have this same issue - create an AboutPage (in the options menu) - select it, hit back press and the
app exits. So (2) steps: set the theme then put in the override code. I'm going to put the override code
in and try to figure out the theme after. Thanks. I've tried so many things.

from android-about-page.

Eight-For-Eight avatar Eight-For-Eight commented on August 19, 2024

I can't make any of this code compile in my app where I have a main activity (fragment), or another fragment. The app is a variation of BluetoothChat and I can't get any of this code to compile no matter where I put it:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ........
        // add back arrow to toolbar
        if (getSupportActionBar() != null){
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onSupportNavigateUp() {
        onBackPressed();
        return true;
    }

I detail the solution I found below.

from android-about-page.

Eight-For-Eight avatar Eight-For-Eight commented on August 19, 2024

I figured out a good, easy way to go back. This works for my main activity which extends a FragmentActivity, and AboutPage is presented from the options menu (with the dots).

Basically I thought about it in terms of having a view and displaying it in a new activity. That led me to the basic android dev page Start Another Activity

developer.android.com/training/basics/firstapp/starting-activity

I followed the tutorial but had to change the type of the activity generated from New Empty Activity from AppCompatActivity to FragmentActivity or the tutorial file would not compile. Then I put the straight AboutPage code into this new activity.

The main issue is to not just fire up an AboutPage from an activity but to start a new activity with an intent and do it there. Now the about page goes back to the app (does not exit) and when returning from visiting the web page from the about page, it does not crash.

I think there may be many ways of hosting the about page and even though I tried a lot of things that didn't work it is probably my shallow android experience, rather than AboutPage which is great. Here's the code - first the options menu item:

case R.id.so_about: {

                // display the page!
                displayAboutPage();

                return true;
            }

/* Called when the user selects About option */
    public void displayAboutPage() {
        // Do something in response to button
        Intent intent = new Intent(this, DisplayAboutPageActivity.class);
        startActivity(intent);
    }

Then the activity:

public class DisplayAboutPageActivity extends FragmentActivity {

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

        Element adsElement = new Element();
        adsElement.setTitle("Advertise with smartOar");
        String version = getResources().getString(R.string.app_version);

        View aboutPage = new AboutPage(this)
                .setDescription("armonitor is smartOar's real-time force curve feedback system utility product, based on Android")
                .isRTL(false)
                .addItem(new Element().setTitle(version))
                .addGroup("Connect with us")
                .addEmail("[email protected]")
                .addWebsite("http://www.smartoar.com")
                .addYoutube("UC1kgLzMza-NP21jiG8keztQ")
                .create();

        setContentView(aboutPage);
    }
}

from android-about-page.

edwinmugendi avatar edwinmugendi commented on August 19, 2024

Use TableLayout and then add the About Page as a view into the TableLayout

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_about);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        if (getSupportActionBar() != null){
            getSupportActionBar().setTitle(getString(R.string.about_sapamacash));
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }//E# if statement

        tableLayout = (TableLayout) findViewById(R.id.aboutLayout);

        String phone = "+254722906835";

        View aboutPage = new AboutPage(this)
                .isRTL(false)
                .setDescription(getString(R.string.about_us_text))
                .addEmail("[email protected]")
                .addItem(getPhoneElement(phone))
                .addWebsite("https://sapamacash.com/")
                .addFacebook("sapamatech")
                .addTwitter("sapamatech")
                .addYoutube("UCV-sIbWJ5HpO0qk6Hp7Sjfw")
                .addItem(getCopyRightsElement())
                .create();

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        aboutPage.setLayoutParams(params);

        tableLayout.addView(aboutPage, 1,params);

    }



<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".ui.activity.AboutActivity"
    android:id="@+id/aboutLayout">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"/>

    </com.google.android.material.appbar.AppBarLayout>

</TableLayout>



from android-about-page.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.