0

when i testing it on my mobile (huawei G8) in vertical view it takes like 5 second to click on any of this 4 buttons in my app

also it leave dark spot in the button for second or 2 in horizontal view it works faster

in emulator it also works fine

java file

package com.example.kemo.videoplayer;

import android.content.Context;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.content.Intent;
import android.widget.Button;
import android.widget.ImageButton;

public class Home extends AppCompatActivity {

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

    final ImageButton facebook1 = (ImageButton)        findViewById(R.id.imageButton);
    facebook1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // your handler code here image 1
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,     Uri.parse("http://www.facebook.com"));
            startActivity(browserIntent);
        }
    });
    final ImageButton youtube1 = (ImageButton)     findViewById(R.id.imageButton2);
    youtube1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // your handler code here image 1
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,     Uri.parse("http://www.youtube.com"));
            startActivity(browserIntent);
        }
    });


    final Button button = (Button) findViewById(R.id.btnabout);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // your handler code here
            Intent intent = new Intent(getBaseContext(), About.class);
            startActivity(intent);
        }
    });

    final Button button1 = (Button) findViewById(R.id.btnaikido);
    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // your handler code here
            Intent intent = new Intent(getBaseContext(), Aikido.class);
            startActivity(intent);
        }
    });

    final Button button2 = (Button) findViewById(R.id.btnv);
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // your handler code here
            Intent intent = new Intent(getBaseContext(),     MainActivity.class);
            startActivity(intent);
        }
    });

    final Button button3 = (Button) findViewById(R.id.btnpic);
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // your handler code here
            Intent intent = new Intent(getBaseContext(), Gview.class);
            startActivity(intent);
        }
    });

}


}

XML file

 <?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"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout 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:id="@+id/activity_home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        tools:context="com.example.kemo.videoplayer.Home">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/imageView3"
            android:layout_height="140dp"
            android:scaleType="fitXY"
            android:background="@drawable/aikidobanner" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btnabout"
            android:layout_margin="5dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/btnaikido"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:text="@string/aikido" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btnaikido"
            android:layout_margin="5dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/btnv"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:text="@string/videos" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btnv"
            android:layout_margin="5dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/btnpic"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:text="@string/gallery" />

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/btnabout"
            android:text="@string/about"
            android:layout_below="@+id/imageView3"
            android:layout_margin="5dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true" />
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageButton
            android:id="@+id/imageButton"
            app:srcCompat="@drawable/facebook"
            android:layout_width="120dp"
            android:layout_height="60dp"
            android:scaleType="fitXY"
            android:layout_marginTop="10dp"
            android:layout_marginRight="25dp"
            android:layout_marginLeft="50dp"

            android:background="@android:color/transparent" />

        <ImageButton
            android:id="@+id/imageButton2"
            app:srcCompat="@drawable/youtube"
            android:layout_width="120dp"
            android:layout_height="60dp"
            android:scaleType="fitXY"
            android:layout_marginTop="10dp"
            android:layout_marginLeft="25dp"
            android:layout_marginRight="50dp"
            android:background="@android:color/transparent" />
    </LinearLayout>

 </LinearLayout>
 </ScrollView>
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Gamal Aly
  • 1
  • 2

2 Answers2

0

It's hard to know for sure without seeing the rest of the app, but this sounds like the new Activities that you are launching are probably doing too much work in their onCreate methods, or doing something heavy-weight in some other method on the UI thread during startup.

From the code you've shown, I think that it's not very likely that it's anything in your Home activity, unless that Activity has something intensive going on in it's UI thread.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
0

Cannot find any obvious wrong from the code you have shown. So If there's no more other code there and problem still exist, I suggest that you should find it through a process of elimination. For example, delete all listener in onCreate and add just one, then keep trying.

machinezhou
  • 679
  • 2
  • 6
  • 16
  • i deleted all and kept only one but still the same slow also the other activities has only pic and text – Gamal Aly Nov 26 '16 at 17:00
  • 1 Maybe should try to replace your content view with a empty xml. 2 check your memory, normally a empty project will occupied 16M around. 3 Dump your memory and find out what cause your problem. – machinezhou Nov 26 '16 at 17:26