SHARE
TWEET

Untitled

a guest Feb 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import android.support.v7.app.AppCompatActivity;
  2. import android.os.Bundle;
  3. import android.view.View;
  4. import android.widget.AdapterView;
  5. import android.widget.ArrayAdapter;
  6. import android.widget.ListView;
  7. import android.widget.Toast;
  8. import java.util.ArrayList;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11.     ListView list;
  12.     @Override
  13.     protected void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         setContentView(R.layout.activity_main);
  16.         list = findViewById(R.id.List);
  17.         ArrayList<String> fd = new ArrayList<String>();
  18.         fd.add("roda");
  19.         fd.add("ghh");
  20.         fd.add("asfff");
  21.         fd.add("jll");
  22.         ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,R.layout.support_simple_spinner_dropdown_item,fd);
  23.         list.setAdapter(arrayAdapter);
  24.         list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  25.             @Override
  26.             public void onItemClick(AdapterView<?> parent, View view, int position, long id)
  27.             {                Toast.makeText(MainActivity.this,"hello",fd.get(position),Toast.LENGTH_LONG).show();
  28.             }
  29.         });
  30.     }
  31. }
  32.      
  33. Toast.makeText(this,"hello",fd.get(position),Toast.LENGTH_LONG).show();
  34.      
  35. Toast.makeText(MainActivity.this,"hello",fd.get(position),Toast.LENGTH_LONG).show();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top