Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android中的可点击线性布局_Java_Android - Fatal编程技术网

Java Android中的可点击线性布局

Java Android中的可点击线性布局,java,android,Java,Android,我想使用LinearLayout作为按钮,实际上我有: LinearLayout Ll; Ll = (LinearLayout) findViewById(R.id.MYID); Ll.setClickable(true); Ll.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { //action } }); 但它不起作用。当

我想使用LinearLayout作为按钮,实际上我有:

LinearLayout Ll;
Ll = (LinearLayout) findViewById(R.id.MYID);
Ll.setClickable(true);
Ll.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View view) {
        //action
    }
});
但它不起作用。当我尝试打开此活动时,它会发出警告:

不幸的是,应用程序已经停止


单击应关闭“活动”并返回“主要”。在“//action”中,我使用了
finish()
,但也有同样的问题。

我在XML的这一部分中添加了id(有很多线性布局,如果我从*.java的第一篇文章中删除codoe,它就会起作用)


希望这对您有所帮助

在XML文件中

 <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/MYID"
      android:clickable="true"
      android:focusable="true">
</LinearLayout>
而且在反压状态下

public void onBackPressed() {
    super.onBackPressed();
    finish();
}

我可能误解了,但是

您的布局id是TrainerBackptn

android:id="@+id/trainersbackbtn"
那你为什么用java调用MYID呢

Ll = (LinearLayout) findViewById(R.id.MYID);
有一个xml代码:

<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/ic_mainback"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.szkola.dd.test1.TrainersActivity"
    tools:showIn="@layout/activity_trainers">

    //info+back
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="20dp"
        android:layout_marginLeft="20dp">
        //1rzad
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:background="#D933777F"
            android:layout_marginRight="10dp"
            android:orientation="horizontal">
            //zdjecie
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:paddingBottom="5dp"
                        android:paddingTop="5dp"
                        android:paddingLeft="10dp"
                        android:src="@drawable/ic_mainphoto"/>
                </RelativeLayout>
            </LinearLayout>
            //nazwa
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:orientation="vertical">
                //imie+nazwisko
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColor="#FFFFFF"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:text="Bartek Haliniak"
                            android:paddingTop="10dp"
                            android:layout_centerInParent="true"/>
                    </RelativeLayout>
                </LinearLayout>
                //info o klubie
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColor="#FFFFFF"
                            android:textSize="16dp"
                            android:textStyle="normal"
                            android:text="Flashdance Wrocław"
                            android:layout_centerInParent="true"/>
                    </RelativeLayout>
                </LinearLayout>

            </LinearLayout>
        </LinearLayout>
        //logout
        <LinearLayout
            android:clickable="true"
            android:focusable="true"
            android:id="@+id/trainersbackbtn"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#B35556FF"
            android:layout_marginLeft="10dp">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_trainersback"
                    android:tint="#FFFFFF"
                    android:layout_centerInParent="true"/>
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>

    //2rzad
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:orientation="horizontal"
        android:layout_marginLeft="20dp"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="20dp">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:layout_marginRight="10dp"
            android:background="#B35556FF">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:src="@drawable/ic_trainerstrainers"
                    android:tint="#FFFFFF"/>
            </RelativeLayout>
        </LinearLayout>
        //trenerzy + nazwa szkoly
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:layout_marginLeft="10dp"
            android:background="#B35556FF"
            android:orientation="vertical">
            //napis trenerzy
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="2"
                android:layout_marginTop="10dp">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp"
                        android:textStyle="bold"
                        android:textColor="#FFFFFF"
                        android:text="Trenerzy"
                        android:layout_centerInParent="true"/>
                </RelativeLayout>
            </LinearLayout>
            //nazwa szkoly
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:layout_marginBottom="20dp">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="15dp"
                        android:textStyle="bold"
                        android:textColor="#FFFFFF"
                        android:text="Flashdance Wroclaw"
                        android:layout_centerInParent="true"/>
                </RelativeLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    //3rzad-lista
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="10"
        android:orientation="horizontal"
        android:layout_marginRight="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="30dp">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/trainerslist">
        </ListView>
    </LinearLayout>

</LinearLayout>

//信息+返回
//1rzad
//zdjecie
//纳兹瓦
//伊米+纳兹维斯科
//克鲁比信息
//注销
//2rzad
//trenerzy+nazwa szkoly
//纳皮斯特伦奇酒店
//纳兹瓦·斯科利
//3rzad lista
和java代码:

package com.szkola.dd.test1;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Layout;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import static android.widget.Toast.*;

public class TrainersActivity extends AppCompatActivity {


    ListView listview;
    int[] list_photo = {R.drawable.alicja, R.drawable.joanna, R.drawable.ic_mainphoto, R.drawable.tomek, R.drawable.kuba};
    String[] list_name = {"Al", "J ", "Ba", "Too", "Ku"};
    String[] list_email = {"alicja@gmail.com", "joanna@wp.pl", "bartek@onet.pl", "tomek@interia.pl", "kuba@o2.pl"};
    String[] list_phone = {"759 ", "643 652 0", "67595", "612 5", "643", "573 2"};
    TrainersAdapter adapter;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {

        LinearLayout Ll = (LinearLayout) findViewById(R.id.trainersbackbtn);
        Ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_trainers);
        listview = (ListView) findViewById(R.id.trainerslist);
        adapter = new TrainersAdapter(getApplicationContext(), R.layout.list_trainers);
        listview.setAdapter(adapter);
        int i = 0;
        for (i = 0; i < 5; i++) {
            TrainersDataProvider dataProvider = new TrainersDataProvider(list_photo[i], list_name[i], list_email[i], list_phone[i]);
            adapter.add(dataProvider);
        }
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Trainers Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.szkola.dd.test1/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Trainers Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.szkola.dd.test1/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }
}
package com.szkola.dd.test1;
导入android.content.Intent;
导入android.net.Uri;
导入android.os.Bundle;
导入android.support.design.widget.FloatingActionButton;
导入android.support.design.widget.Snackbar;
导入android.support.v7.app.AppActivity;
导入android.support.v7.widget.Toolbar;
导入android.text.Layout;
导入android.view.view;
导入android.widget.Button;
导入android.widget.LinearLayout;
导入android.widget.ListView;
导入android.widget.Toast;
导入com.google.android.gms.appindexing.Action;
导入com.google.android.gms.AppIndex.AppIndex;
导入com.google.android.gms.common.api.GoogleAppClient;
导入静态android.widget.Toast.*;
公共类TrainerActivity扩展了AppCompative活动{
列表视图列表视图;
int[]list_photo={R.drawable.alicja,R.drawable.joanna,R.drawable.ic_mainphoto,R.drawable.tomek,R.drawable.kuba};
String[]list_name={“Al”、“J”、“Ba”、“Too”、“Ku”};
字符串[]列表\电子邮件={”alicja@gmail.com", "joanna@wp.pl", "bartek@onet.pl", "tomek@interia.pl", "kuba@o2.pl"};
String[]list_phone={“759”、“643 652 0”、“67595”、“612 5”、“643”、“573 2”};
列车适配器;
/**
*注意:这是自动生成的,用于实现应用程序索引API。
*看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
*/
私人谷歌客户;
public void onBackPressed(){
super.onBackPressed();
完成();
}
@凌驾
创建时受保护的void(Bundle savedInstanceState){
LinearLayout Ll=(LinearLayout)findViewById(R.id.TrainersBackptn);
Ll.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
完成();
}
});
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_);
listview=(listview)findViewById(R.id.TrainerList);
适配器=新培训师适配器(getApplicationContext(),R.layout.list\u培训师);
setAdapter(适配器);
int i=0;
对于(i=0;i<5;i++){
TrainerDataProvider dataProvider=新的TrainerDataProvider(列表照片[i]、列表姓名[i]、列表电子邮件[i]、列表电话[i]);
adapter.add(数据提供者);
}
//注意:这是自动生成的,用于实现应用程序索引API。
//看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
client=new GoogleApiClient.Builder(this.addApi(AppIndex.API).build();
}
@凌驾
public void onStart(){
super.onStart();
//注意:这是自动生成的,用于实现应用程序索引API。
//看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
client.connect();
Action viewAction=Action.newAction(
Action.TYPE\u视图,//TODO:选择一种操作类型。
“培训师页面”//TODO:为显示的内容定义标题。
//TODO:如果您的网页内容与此应用程序活动的内容匹配,
//确保此自动生成的网页URL正确无误。
//否则,请将URL设置为null。
解析http://host/path"),
//TODO:确保此自动生成的应用程序深度链接URI正确。
解析-app://com.szkola.dd.test1/http/host/path")
);
AppIndex.AppIndexApi.start(客户端,viewAction);
}
@凌驾
公共void onStop(){
super.onStop();
//注意:这是自动生成的,用于实现应用程序索引API。
//看https://g.co/AppIndexing/AndroidStudio 了解更多信息。
Action viewAction=Action.newAction(
Action.TYPE\u视图,//TODO:选择一种操作类型。
“培训师页面”//TODO:为显示的内容定义标题。
//TODO:如果您的网页内容与此应用程序活动的内容匹配,
//确保此自动生成的网页URL正确无误。
//否则,请将URL设置为null。
解析http://host/path"),
//TODO:确保此自动生成的应用程序
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/ic_mainback"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.szkola.dd.test1.TrainersActivity"
    tools:showIn="@layout/activity_trainers">

    //info+back
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight="20dp"
        android:layout_marginLeft="20dp">
        //1rzad
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:background="#D933777F"
            android:layout_marginRight="10dp"
            android:orientation="horizontal">
            //zdjecie
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:paddingBottom="5dp"
                        android:paddingTop="5dp"
                        android:paddingLeft="10dp"
                        android:src="@drawable/ic_mainphoto"/>
                </RelativeLayout>
            </LinearLayout>
            //nazwa
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2"
                android:orientation="vertical">
                //imie+nazwisko
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColor="#FFFFFF"
                            android:textSize="25dp"
                            android:textStyle="bold"
                            android:text="Bartek Haliniak"
                            android:paddingTop="10dp"
                            android:layout_centerInParent="true"/>
                    </RelativeLayout>
                </LinearLayout>
                //info o klubie
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content">
                    <RelativeLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content">
                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColor="#FFFFFF"
                            android:textSize="16dp"
                            android:textStyle="normal"
                            android:text="Flashdance Wrocław"
                            android:layout_centerInParent="true"/>
                    </RelativeLayout>
                </LinearLayout>

            </LinearLayout>
        </LinearLayout>
        //logout
        <LinearLayout
            android:clickable="true"
            android:focusable="true"
            android:id="@+id/trainersbackbtn"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="#B35556FF"
            android:layout_marginLeft="10dp">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_trainersback"
                    android:tint="#FFFFFF"
                    android:layout_centerInParent="true"/>
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>

    //2rzad
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:orientation="horizontal"
        android:layout_marginLeft="20dp"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginRight="20dp">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:layout_marginRight="10dp"
            android:background="#B35556FF">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:src="@drawable/ic_trainerstrainers"
                    android:tint="#FFFFFF"/>
            </RelativeLayout>
        </LinearLayout>
        //trenerzy + nazwa szkoly
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"
            android:layout_marginLeft="10dp"
            android:background="#B35556FF"
            android:orientation="vertical">
            //napis trenerzy
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="2"
                android:layout_marginTop="10dp">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="25dp"
                        android:textStyle="bold"
                        android:textColor="#FFFFFF"
                        android:text="Trenerzy"
                        android:layout_centerInParent="true"/>
                </RelativeLayout>
            </LinearLayout>
            //nazwa szkoly
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:layout_marginBottom="20dp">
                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="15dp"
                        android:textStyle="bold"
                        android:textColor="#FFFFFF"
                        android:text="Flashdance Wroclaw"
                        android:layout_centerInParent="true"/>
                </RelativeLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

    //3rzad-lista
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="10"
        android:orientation="horizontal"
        android:layout_marginRight="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="30dp">

        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/trainerslist">
        </ListView>
    </LinearLayout>

</LinearLayout>
package com.szkola.dd.test1;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Layout;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Toast;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

import static android.widget.Toast.*;

public class TrainersActivity extends AppCompatActivity {


    ListView listview;
    int[] list_photo = {R.drawable.alicja, R.drawable.joanna, R.drawable.ic_mainphoto, R.drawable.tomek, R.drawable.kuba};
    String[] list_name = {"Al", "J ", "Ba", "Too", "Ku"};
    String[] list_email = {"alicja@gmail.com", "joanna@wp.pl", "bartek@onet.pl", "tomek@interia.pl", "kuba@o2.pl"};
    String[] list_phone = {"759 ", "643 652 0", "67595", "612 5", "643", "573 2"};
    TrainersAdapter adapter;
    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {

        LinearLayout Ll = (LinearLayout) findViewById(R.id.trainersbackbtn);
        Ll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_trainers);
        listview = (ListView) findViewById(R.id.trainerslist);
        adapter = new TrainersAdapter(getApplicationContext(), R.layout.list_trainers);
        listview.setAdapter(adapter);
        int i = 0;
        for (i = 0; i < 5; i++) {
            TrainersDataProvider dataProvider = new TrainersDataProvider(list_photo[i], list_name[i], list_email[i], list_phone[i]);
            adapter.add(dataProvider);
        }
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Trainers Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.szkola.dd.test1/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Trainers Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app deep link URI is correct.
                Uri.parse("android-app://com.szkola.dd.test1/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trainers);
setContentView(R.layout.activity_trainers);
LinearLayout Ll = (LinearLayout) findViewById(R.id.trainersbackbtn);
Ll.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View view) {
         finish();
      }
    });