Why I can't setOnItemClickListener from gridview in Asynctask Class?












0














i want to view the toast, but my setOnItemClickListener is not working.



this is my class for asynctask



private GridView listView;

class jadwall extends AsyncTask<String, String, String>
{
private String val3;


public jadwall(String a) {
this.val3 = a;
// Do something ...
}
@Override
protected String doInBackground(String... strings) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
CallSoap cs = new CallSoap();
data = cs.JadwalHarian(val3);

return data;
}

@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//Toast.makeText(JadwalDokter.this,s.toString(),Toast.LENGTH_SHORT).show();
ArrayList<String> jadwalList = new ArrayList<String>();
try {
String data1 = s.split("%");
for (int i = 0; i < data1.length-1; i++) {
String data2 = data1[i].split("#");
jadwalList.add(data2[1].substring(1));
}
}catch (Exception e){
Toast.makeText(JadwalDokter.this,e.toString(),Toast.LENGTH_SHORT).show();
}
listView.setAdapter(new JadwalDokterAdapter(JadwalDokter.this, jadwalList));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
}
});

}
}


this is my class. and i want to view the toast in grid. but i don't know hot to pop the toast. i'm done with the grid. but i don't see the setOnItemClickListener is working



This is my getview() in my adapter



public View getView(int position, View convertView, ViewGroup parent) {

LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View gridView;

if (convertView == null) {

gridView = new View(context);

// get layout from mobile.xml
gridView = inflater.inflate(R.layout.user_row_jadwal, null);

// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.name);
TextView textViewphone = (TextView) gridView
.findViewById(R.id.phone);

textView.setText(mobileValues.get(position));
} else {
gridView = (View) convertView;
}

return gridView;
}


this is my XML for my view



<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="info.androidhive.recyclerviewsearch.JadwalDokter"
tools:showIn="@layout/activity_jadwal_dokter">

<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="@+id/calendarView"
>

<GridView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="49dp"
android:scrollbars="vertical"
android:focusable="false"
android:focusableInTouchMode="false"/>
</RelativeLayout>




and this is my user_row_jadwal



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:paddingBottom="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/thumbnail"
android:fontFamily="sans-serif-medium"
android:textColor="@color/contact_name"
android:textSize="@dimen/contact_name" />

<TextView
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_toRightOf="@id/thumbnail"
android:textColor="@color/contact_number"
android:textSize="@dimen/contact_number" />











share|improve this question
























  • Could you post your getView of your adapter and its layout XML?
    – Aaron
    Nov 21 at 3:16










  • You have messed up inside getView() follow some tutorial for grid view . Like gridView = new View(context); is use less here .
    – ADM
    Nov 21 at 3:54
















0














i want to view the toast, but my setOnItemClickListener is not working.



this is my class for asynctask



private GridView listView;

class jadwall extends AsyncTask<String, String, String>
{
private String val3;


public jadwall(String a) {
this.val3 = a;
// Do something ...
}
@Override
protected String doInBackground(String... strings) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
CallSoap cs = new CallSoap();
data = cs.JadwalHarian(val3);

return data;
}

@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//Toast.makeText(JadwalDokter.this,s.toString(),Toast.LENGTH_SHORT).show();
ArrayList<String> jadwalList = new ArrayList<String>();
try {
String data1 = s.split("%");
for (int i = 0; i < data1.length-1; i++) {
String data2 = data1[i].split("#");
jadwalList.add(data2[1].substring(1));
}
}catch (Exception e){
Toast.makeText(JadwalDokter.this,e.toString(),Toast.LENGTH_SHORT).show();
}
listView.setAdapter(new JadwalDokterAdapter(JadwalDokter.this, jadwalList));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
}
});

}
}


this is my class. and i want to view the toast in grid. but i don't know hot to pop the toast. i'm done with the grid. but i don't see the setOnItemClickListener is working



This is my getview() in my adapter



public View getView(int position, View convertView, ViewGroup parent) {

LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View gridView;

if (convertView == null) {

gridView = new View(context);

// get layout from mobile.xml
gridView = inflater.inflate(R.layout.user_row_jadwal, null);

// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.name);
TextView textViewphone = (TextView) gridView
.findViewById(R.id.phone);

textView.setText(mobileValues.get(position));
} else {
gridView = (View) convertView;
}

return gridView;
}


this is my XML for my view



<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="info.androidhive.recyclerviewsearch.JadwalDokter"
tools:showIn="@layout/activity_jadwal_dokter">

<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="@+id/calendarView"
>

<GridView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="49dp"
android:scrollbars="vertical"
android:focusable="false"
android:focusableInTouchMode="false"/>
</RelativeLayout>




and this is my user_row_jadwal



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:paddingBottom="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/thumbnail"
android:fontFamily="sans-serif-medium"
android:textColor="@color/contact_name"
android:textSize="@dimen/contact_name" />

<TextView
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_toRightOf="@id/thumbnail"
android:textColor="@color/contact_number"
android:textSize="@dimen/contact_number" />











share|improve this question
























  • Could you post your getView of your adapter and its layout XML?
    – Aaron
    Nov 21 at 3:16










  • You have messed up inside getView() follow some tutorial for grid view . Like gridView = new View(context); is use less here .
    – ADM
    Nov 21 at 3:54














0












0








0







i want to view the toast, but my setOnItemClickListener is not working.



this is my class for asynctask



private GridView listView;

class jadwall extends AsyncTask<String, String, String>
{
private String val3;


public jadwall(String a) {
this.val3 = a;
// Do something ...
}
@Override
protected String doInBackground(String... strings) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
CallSoap cs = new CallSoap();
data = cs.JadwalHarian(val3);

return data;
}

@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//Toast.makeText(JadwalDokter.this,s.toString(),Toast.LENGTH_SHORT).show();
ArrayList<String> jadwalList = new ArrayList<String>();
try {
String data1 = s.split("%");
for (int i = 0; i < data1.length-1; i++) {
String data2 = data1[i].split("#");
jadwalList.add(data2[1].substring(1));
}
}catch (Exception e){
Toast.makeText(JadwalDokter.this,e.toString(),Toast.LENGTH_SHORT).show();
}
listView.setAdapter(new JadwalDokterAdapter(JadwalDokter.this, jadwalList));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
}
});

}
}


this is my class. and i want to view the toast in grid. but i don't know hot to pop the toast. i'm done with the grid. but i don't see the setOnItemClickListener is working



This is my getview() in my adapter



public View getView(int position, View convertView, ViewGroup parent) {

LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View gridView;

if (convertView == null) {

gridView = new View(context);

// get layout from mobile.xml
gridView = inflater.inflate(R.layout.user_row_jadwal, null);

// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.name);
TextView textViewphone = (TextView) gridView
.findViewById(R.id.phone);

textView.setText(mobileValues.get(position));
} else {
gridView = (View) convertView;
}

return gridView;
}


this is my XML for my view



<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="info.androidhive.recyclerviewsearch.JadwalDokter"
tools:showIn="@layout/activity_jadwal_dokter">

<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="@+id/calendarView"
>

<GridView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="49dp"
android:scrollbars="vertical"
android:focusable="false"
android:focusableInTouchMode="false"/>
</RelativeLayout>




and this is my user_row_jadwal



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:paddingBottom="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/thumbnail"
android:fontFamily="sans-serif-medium"
android:textColor="@color/contact_name"
android:textSize="@dimen/contact_name" />

<TextView
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_toRightOf="@id/thumbnail"
android:textColor="@color/contact_number"
android:textSize="@dimen/contact_number" />











share|improve this question















i want to view the toast, but my setOnItemClickListener is not working.



this is my class for asynctask



private GridView listView;

class jadwall extends AsyncTask<String, String, String>
{
private String val3;


public jadwall(String a) {
this.val3 = a;
// Do something ...
}
@Override
protected String doInBackground(String... strings) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
CallSoap cs = new CallSoap();
data = cs.JadwalHarian(val3);

return data;
}

@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
//Toast.makeText(JadwalDokter.this,s.toString(),Toast.LENGTH_SHORT).show();
ArrayList<String> jadwalList = new ArrayList<String>();
try {
String data1 = s.split("%");
for (int i = 0; i < data1.length-1; i++) {
String data2 = data1[i].split("#");
jadwalList.add(data2[1].substring(1));
}
}catch (Exception e){
Toast.makeText(JadwalDokter.this,e.toString(),Toast.LENGTH_SHORT).show();
}
listView.setAdapter(new JadwalDokterAdapter(JadwalDokter.this, jadwalList));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
}
});

}
}


this is my class. and i want to view the toast in grid. but i don't know hot to pop the toast. i'm done with the grid. but i don't see the setOnItemClickListener is working



This is my getview() in my adapter



public View getView(int position, View convertView, ViewGroup parent) {

LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View gridView;

if (convertView == null) {

gridView = new View(context);

// get layout from mobile.xml
gridView = inflater.inflate(R.layout.user_row_jadwal, null);

// set value into textview
TextView textView = (TextView) gridView
.findViewById(R.id.name);
TextView textViewphone = (TextView) gridView
.findViewById(R.id.phone);

textView.setText(mobileValues.get(position));
} else {
gridView = (View) convertView;
}

return gridView;
}


this is my XML for my view



<RelativeLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="info.androidhive.recyclerviewsearch.JadwalDokter"
tools:showIn="@layout/activity_jadwal_dokter">

<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_below="@+id/calendarView"
>

<GridView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="49dp"
android:scrollbars="vertical"
android:focusable="false"
android:focusableInTouchMode="false"/>
</RelativeLayout>




and this is my user_row_jadwal



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:paddingBottom="25dp"
android:paddingLeft="25dp"
android:paddingRight="25dp"
android:paddingTop="25dp">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/thumbnail"
android:fontFamily="sans-serif-medium"
android:textColor="@color/contact_name"
android:textSize="@dimen/contact_name" />

<TextView
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_toRightOf="@id/thumbnail"
android:textColor="@color/contact_number"
android:textSize="@dimen/contact_number" />








android gridview android-asynctask android-toast






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 3:25

























asked Nov 21 at 3:12









andry sim

11




11












  • Could you post your getView of your adapter and its layout XML?
    – Aaron
    Nov 21 at 3:16










  • You have messed up inside getView() follow some tutorial for grid view . Like gridView = new View(context); is use less here .
    – ADM
    Nov 21 at 3:54


















  • Could you post your getView of your adapter and its layout XML?
    – Aaron
    Nov 21 at 3:16










  • You have messed up inside getView() follow some tutorial for grid view . Like gridView = new View(context); is use less here .
    – ADM
    Nov 21 at 3:54
















Could you post your getView of your adapter and its layout XML?
– Aaron
Nov 21 at 3:16




Could you post your getView of your adapter and its layout XML?
– Aaron
Nov 21 at 3:16












You have messed up inside getView() follow some tutorial for grid view . Like gridView = new View(context); is use less here .
– ADM
Nov 21 at 3:54




You have messed up inside getView() follow some tutorial for grid view . Like gridView = new View(context); is use less here .
– ADM
Nov 21 at 3:54












2 Answers
2






active

oldest

votes


















0














Simply remove android:clickable="true" from RelativeLayout in your user_row_jadwal.xml.



In a ListView, whenever an item view is being clicked, it will perform View.hasExplicitFocusable on the view, so if there is any clickable view on your item view, then you will not receive callback in onItemClick.






share|improve this answer





















  • is working. thank you
    – andry sim
    Nov 21 at 7:56










  • You're welcome, please consider to accept this answer if it works.
    – Aaron
    Nov 21 at 8:03



















0














Add a click listener in your getView method just before the return gridView.



gridView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
}
});





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404764%2fwhy-i-cant-setonitemclicklistener-from-gridview-in-asynctask-class%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Simply remove android:clickable="true" from RelativeLayout in your user_row_jadwal.xml.



    In a ListView, whenever an item view is being clicked, it will perform View.hasExplicitFocusable on the view, so if there is any clickable view on your item view, then you will not receive callback in onItemClick.






    share|improve this answer





















    • is working. thank you
      – andry sim
      Nov 21 at 7:56










    • You're welcome, please consider to accept this answer if it works.
      – Aaron
      Nov 21 at 8:03
















    0














    Simply remove android:clickable="true" from RelativeLayout in your user_row_jadwal.xml.



    In a ListView, whenever an item view is being clicked, it will perform View.hasExplicitFocusable on the view, so if there is any clickable view on your item view, then you will not receive callback in onItemClick.






    share|improve this answer





















    • is working. thank you
      – andry sim
      Nov 21 at 7:56










    • You're welcome, please consider to accept this answer if it works.
      – Aaron
      Nov 21 at 8:03














    0












    0








    0






    Simply remove android:clickable="true" from RelativeLayout in your user_row_jadwal.xml.



    In a ListView, whenever an item view is being clicked, it will perform View.hasExplicitFocusable on the view, so if there is any clickable view on your item view, then you will not receive callback in onItemClick.






    share|improve this answer












    Simply remove android:clickable="true" from RelativeLayout in your user_row_jadwal.xml.



    In a ListView, whenever an item view is being clicked, it will perform View.hasExplicitFocusable on the view, so if there is any clickable view on your item view, then you will not receive callback in onItemClick.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 at 4:19









    Aaron

    1,7051212




    1,7051212












    • is working. thank you
      – andry sim
      Nov 21 at 7:56










    • You're welcome, please consider to accept this answer if it works.
      – Aaron
      Nov 21 at 8:03


















    • is working. thank you
      – andry sim
      Nov 21 at 7:56










    • You're welcome, please consider to accept this answer if it works.
      – Aaron
      Nov 21 at 8:03
















    is working. thank you
    – andry sim
    Nov 21 at 7:56




    is working. thank you
    – andry sim
    Nov 21 at 7:56












    You're welcome, please consider to accept this answer if it works.
    – Aaron
    Nov 21 at 8:03




    You're welcome, please consider to accept this answer if it works.
    – Aaron
    Nov 21 at 8:03













    0














    Add a click listener in your getView method just before the return gridView.



    gridView.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View view){
    Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
    }
    });





    share|improve this answer


























      0














      Add a click listener in your getView method just before the return gridView.



      gridView.setOnClickListener(new View.OnClickListener(){
      @Override
      public void onClick(View view){
      Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
      }
      });





      share|improve this answer
























        0












        0








        0






        Add a click listener in your getView method just before the return gridView.



        gridView.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View view){
        Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
        }
        });





        share|improve this answer












        Add a click listener in your getView method just before the return gridView.



        gridView.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(View view){
        Toast.makeText(JadwalDokter.this,((TextView) view.findViewById(R.id.name)).getText(),Toast.LENGTH_SHORT).show();
        }
        });






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 6:42









        SHAH MD MONIRUL ISLAM

        1,07531327




        1,07531327






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404764%2fwhy-i-cant-setonitemclicklistener-from-gridview-in-asynctask-class%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'