1. Download our Official Android App: Forums for Android!

app development

Discussion in 'Android Development' started by Steven Spiegel, Aug 10, 2018.

  1. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    I am developing an app. Wish for it to scroll <ScrollView> code not working. Can anyone help me please?
    I can upload my content_main.xml file.
     

    Advertisement

  2. kate

    kate Dreaming of Bugdroid.
    Moderator
    Rank:
     #42
    Points:
    618
    Posts:
    5,458
    Joined:
    Aug 14, 2013

    Unforgiven and LV426 like this.
  3. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    thanks Kate. the place you put it is more appropriate.
     
    Unforgiven likes this.
  4. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,634
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,634
    11,035
    1,988
    Male
    Software developer
    South West of England
    Need to see your code, and you need to explain what you mean by "not working".
     
  5. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    thanks so much for willing to help me. the code will follow. this xml file with the modifications I did will not open.
    my intent is to have full vertical scroll.
    now the code:
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView
    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="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@String/appbar_scrolling_view_behavior"
    tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
    tools:showIn="@layout/activity_main">


    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView"
    android:layout_alignParentStart="true"
    android:layout_marginTop="56dp" />
    <ImageView android:id="@+id/imageView"
    android:layout_column="1"
    android:background="@Mipmap/lpussy"
    android:contentDescription='android:ContentDescription="@String/desc"'
    tools:ignore="HardcodedText"
    android:layout_width="200dp"
    android:layout_height="230dp" />


    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=" We&apos;ve been serving good people with special deals. "
    android:id="@+id/text1"
    android:layout_alignTop="@+id/imageView"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:background="#ffffff"
    android:foreground="#05ffffff"
    android:foregroundTint="#03ffffff"
    android:textColor="#000000" />



    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText2"
    android:text="Cancun, Playa del Carmen"
    android:layout_below="@+id/text1"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:text="Holbox, Taxco, Palenque"
    android:layout_below="@+id/editText2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

    <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="@Mipmap/campa"
    tools:ignore="ContentDescription"
    android:layout_alignBottom="@+id/editText5" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:ems="10"
    android:id="@+id/editText3"
    android:text="thewebmaster@cancunsteve.com"
    android:layout_below="@+id/editText"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/editText"
    android:layout_alignEnd="@+id/editText" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="phone"
    android:ems="10"
    android:id="@+id/editText4"
    android:text=" 011 52 998 8873919"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="42dp"
    android:layout_marginStart="32dp" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText5"
    android:text="be sure to visit us for up to 55% discounts on your hotel bookings"
    android:layout_below="@+id/editText4"
    android:layout_toRightOf="@+id/scrollView"
    android:layout_toEndOf="@+id/scrollView" />

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="click buttons multiple times to change state"
    android:id="@+id/textView2"
    android:layout_below="@+id/imageButton" />

    </LinearLayout>
    </ScrollView>

    </RelativeLayout>
     
  6. wseng92

    wseng92 Well-Known Member
    Rank:
     #436
    Points:
    28
    Posts:
    77
    Joined:
    Oct 26, 2015

    Oct 26, 2015
    77
    13
    28
    Male
    You have closed Linear Layout tag

    Code (Text):
    1. android:layout_height="230dp" />
    The correct should be

    Code (Text):
    1. android:layout_height="230dp" >
     
  7. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    taking out the backshlash did not work but thanks.
    the file opens now with this code below, BUT DOES NOT SCROLL
    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView
    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="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@String/appbar_scrolling_view_behavior"
    tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
    tools:showIn="@layout/activity_main">


    <RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:eek:rientation="vertical" >

    <RelativeLayout
    android:id="@+id/scrollView"
    android:layout_alignParentStart="true"
    android:layout_marginTop="56dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
    <ImageView android:id="@+id/imageView"
    android:layout_column="1"
    android:background="@Mipmap/lpussy"
    android:contentDescription='android:ContentDescription="@String/desc"'
    tools:ignore="HardcodedText"
    android:layout_width="200dp"
    android:layout_height="230dp" />


    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text=" We&apos;ve been serving good people like you since 1994 with special deals on their travel plans. "
    android:id="@+id/text1"
    android:layout_alignTop="@+id/imageView"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:background="#ffffff"
    android:foreground="#05ffffff"
    android:foregroundTint="#03ffffff"
    android:textColor="#000000" />



    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText2"
    android:text="Cancun, Playa del Carmen, Tulum, Cozumel, Isla Mujeres, Merida, Valladolid, Chichen Itza."
    android:layout_below="@+id/text1"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:text="Holbox, Taxco, Palenque, Acapulco, Ixtapa, Guanajuato, Guadalajara, Mexico City, Cabo San Lucas, Puerto Vallarta, Monterrey, Tenacatita, Mascota"
    android:layout_below="@+id/editText2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

    <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="@Mipmap/campa"
    tools:ignore="ContentDescription"
    android:layout_alignBottom="@+id/editText5" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:ems="10"
    android:id="@+id/editText3"
    android:text="thewebmaster@cancunsteve.com"
    android:layout_below="@+id/editText"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/editText"
    android:layout_alignEnd="@+id/editText" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="phone"
    android:ems="10"
    android:id="@+id/editText4"
    android:text=" 011 52 998 8873919"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="42dp"
    android:layout_marginStart="32dp" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText5"
    android:text="be sure to visit us at www.cancunsteve.com for up to 65% discounts on your hotel bookings"
    android:layout_below="@+id/editText4"
    android:layout_toRightOf="@+id/ScrollView"
    android:layout_toEndOf="@+id/ScrollView" />

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="click buttons multiple times to change state"
    android:id="@+id/textView2"
    android:layout_below="@+id/imageButton" />




    </RelativeLayout>
    </ScrollView>
     
  8. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    in the mainactivity.java file below getting errors when attempting to build app
    please help me fix errors.

    Code (Text):
    1.  
    2. public class MainActivity extends AppCompatActivity {
    3.     private Button mButton;
    4.     [USER=1021285]@override[/USER]
    5.     protected void onCreate(Bundle savedInstanceState) {
    6.         super.onCreate(savedInstanceState);
    7.         setContentView(R.layout.activity_main);
    8.         Button activityButton = (Button) findViewById(R.id.button_quiz);
    9.         activity@Button.setOnClick(value = new OnClickListener(),
    10.                 toolbar = (Toolbar) findViewById(R.id.toolbar), setSupportActionBar = (toolbar), mButton = (Button) findViewById(R.id.button_quiz), mButton =, setOnClickListener = (new OnClickListener() {
    11.             [USER=1021285]@override[/USER]
    12.             public void onClick(View view) {
    13.                 //open url using Intent
    14.                 String url = "http://www.cancunsteve.com/capecod/mobilepopquiz2.htm";
    15.                 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    16.  
    17.  
    18.             }
    19.         }
    20.  
     
    #8 Steven Spiegel, Aug 21, 2018
    Last edited by a moderator: Aug 21, 2018
  9. wseng92

    wseng92 Well-Known Member
    Rank:
     #436
    Points:
    28
    Posts:
    77
    Joined:
    Oct 26, 2015

    Oct 26, 2015
    77
    13
    28
    Male
    What errors you getting?
     
  10. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    what errors am I not getting!
    OnClickListener is abstract cannot be instantiated
    cannot resolve activity (this refers to activity@Button)
    in find ViewById(R.id.toolbar) it says attribute value must be constant
    ")" expected (where I have two } )
    ; expected (same place)

    is there any hope??????????
     
  11. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,634
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,634
    11,035
    1,988
    Male
    Software developer
    South West of England
    Your code has so many problems, I don't know where to start. Well let's begin with this

    Code (Text):
    1.  
    2. activity@Button
    3.  
    If you can't see why that's a problem, stop coding now, and pick up the first book you find on Java, and start reading. If you're doing cut/paste coding, then try to understand the code you're using. Otherwise you'll have endless problems, and you'll never achieve anything.

    So tell me, what do you think that statement at line 9 is trying to do?
     
  12. kate

    kate Dreaming of Bugdroid.
    Moderator
    Rank:
     #42
    Points:
    618
    Posts:
    5,458
    Joined:
    Aug 14, 2013

    Lines 4 and 11 got messed up by the forum auto-linking to a user name with USER.

    @Steven Spiegel when you post code use code tags:

    [code]
    Your
    code
    here
    [/code]
     
  13. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    the click listener is to know if the button is activated (clicked) this button loads the url in question
    not sure why it calls a new click listener though
    will follow your advice for posting code
    bought an expensive book on android coding but it explains more to open new activity
    if all else fails will go that route
     
  14. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,634
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,634
    11,035
    1,988
    Male
    Software developer
    South West of England
    However expensive the book you bought, I'll bet it doesn't explain the basics of the Java programming language.
    You need to do the foundation work before you can build the house.
     
  15. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    thanks for your help
     
  16. wseng92

    wseng92 Well-Known Member
    Rank:
     #436
    Points:
    28
    Posts:
    77
    Joined:
    Oct 26, 2015

    Oct 26, 2015
    77
    13
    28
    Male
  17. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    thanks will try
     
    wseng92 likes this.
  18. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    have two errors stemming from the manifest when trying to compile.
    my mainactivity.java is fine I believe.
    the errors are cannot find activity class NewActivity2. cannot find symbol variable activity_main
    manifest below:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cancunsteve.aboutcancunsteve"
    android:installLocation="preferExternal">

    <uses-sdk android:minSdkVersion="19" />


    <application
    android:allowBackup="true"
    android:icon="@Mipmap/appicon"
    android:label="@String/app_name"
    android:supportsRtl="true"
    android:theme="@Style/AppTheme">
    <activity
    android:name=".MainActivity"
    android:label="@String/app_name"
    android:theme="@Style/AppTheme.NoActionBar">
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    </activity>
    <activity
    android:name=".NewActivity2"
    android:label="@String/title_activity_main2"
    android:parentActivityName=".MainActivity"
    android:theme="@Style/AppTheme.NoActionBar">
    <meta-data
    android:name="android.support.PARENT_ACTIVITY"
    android:value="com.cancunsteve.aboutcancunsteve.MainActivity" />
    </activity>
    </application>

    </manifest>
     
  19. wseng92

    wseng92 Well-Known Member
    Rank:
     #436
    Points:
    28
    Posts:
    77
    Joined:
    Oct 26, 2015

    Oct 26, 2015
    77
    13
    28
    Male
    Did your MainActivity java class extend to AppCompatActivity ?
     
  20. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    believe so here is an excerpt (hope I did it correctly)

    Code (Text):
    1. public class MainActivity extends AppCompatActivity {
    2.     Button button;
    3.  
    4.     @Override
    5.     public void onCreate(Bundle savedInstanceState) {
    6.         super.onCreate(savedInstanceState);
    7.         // Get the view from activity_main.xml
    8.         setContentView(R.layout.activity_main);
    9.  
    10.         // Locate the button in activity_main.xml
    11.         button = (Button) findViewById(R.id.MyButton);
    12.  
    13.         // Capture button clicks
    14.         button.setOnClickListener(new OnClickListener() {
    15.             public void onClick(View arg0) {
    16.  
    17.                 // Start NewActivity.class
    18.                 Intent myIntent = new Intent(MainActivity.this,
    19.                         NewActivity2.class);
    20.                 startActivity(myIntent);
    21.             }
    22.         });
    23.     }
     
  21. wseng92

    wseng92 Well-Known Member
    Rank:
     #436
    Points:
    28
    Posts:
    77
    Joined:
    Oct 26, 2015

    Oct 26, 2015
    77
    13
    28
    Male
    MainActivity java class looked good.

    Look at this errors again
    Do you have NewActivity2 java class ?
    If yes, did the class extends to AppCompatActivity ?
     
  22. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,634
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,634
    11,035
    1,988
    Male
    Software developer
    South West of England
    Use the full package name of this class.
     
    wseng92 likes this.
  23. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    in my mainactivity.java I do not have NewActivity2 java class. nor am I sure the correct way to enter it correctly
    now I have
    Code (Text):
    1.  
    2. public class MainActivity extends AppCompatActivity {
    3.     Button button;
    4.  
    5.     @Override
    6.     public void onCreate(Bundle savedInstanceState) {
    7.         super.onCreate(savedInstanceState);
    8.         // Get the view from activity_main.xml
    9.         setContentView(R.layout.activity_main);
    10.  
    11.         // Locate the button in activity_main.xml
    12.         button = (Button) findViewById(R.id.MyButton);
    13.  
    14.         // Capture button clicks
    15.         button.setOnClickListener(new OnClickListener() {
    16.             public void onClick(View arg0) {
    17.  
    18.                 // Start NewActivity.class
    19.                 Intent myIntent = new Intent(MainActivity.this,
    20.                         NewActivity2.class);
    21.                 startActivity(myIntent);
    22.             }
    23.         });
    24.     }
    should I put public class NewActivity2 extends AppCompatActivity {
    Button button;
    then all the same code after @override as above? not sure?
     
  24. wseng92

    wseng92 Well-Known Member
    Rank:
     #436
    Points:
    28
    Posts:
    77
    Joined:
    Oct 26, 2015

    Oct 26, 2015
    77
    13
    28
    Male
    When button in MainActivity is clicked, it should open NewActivity2 (that's what I can see from your code).
    So you have to create NewActivity2 class and do whatever you want in that class.
     
  25. Steven Spiegel

    Thread Starter
    Rank:
     #486
    Points:
    26
    Posts:
    33
    Joined:
    Aug 10, 2018

    Aug 10, 2018
    33
    2
    26
    I just want the NewActivity2.class to open and display the content of activity_main2.xml but not sure the correct coding for that
     

Share This Page

Loading...