android - onclick listview in oncreate() -


I have to set the adapter to the values ​​of my async work and onpostexecute () and when I click on the items in the list view Oncraete () It's not showing anything and I'm trying to show a toast to test it.

  Crate on public void (bundle extractor) {super.onCreate (icicle); SetContentView (R.layout.activity_main); Lv = (ListView) findViewById (R.id.list); New Ftpclient () Executed (); lv.setOnItemClickListener (New OnItemClickListener () {public void onItemClick (AdapterView & LT ;? & gt; parent, and see, int position, long id) {if (state == 0) {Toast.makeText (getApplicationContext ( ), "clicked", 500) Kshow; string f = "FILE54.pdf"; file = new file (environment .getExternalStorageDirectory () + '/ FtpFiles "+ f), if (Filekexists ()) {Uri filepath = Uri.fromFile (file); intent intent = new intent (Intent.ACTION_VIEW); intent.setDataAndType (filepath, "application / pdf"); intent.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP); try {startActivity (effect) ;} Grip (exception e) {toast. GetApplicationContex ("Error", "" + E);}}}}); class Ftpclient asyncTask and lt; string, zero, arreelist & lt; string & gt; & gt; {Arre list & lt; string & gt; Temparrlist = new Arrelist & lt; string & gt; (); progress dialog dialogue; safety zero (on Preefeksut) {dialog = ProgressDialog.show (MainActivity.This, "connecting ", "please wait"); } Safe ArrayList & lt; String & gt; DoInBackground (string ... connection) {temparrlist = listftpitems (); Return temp list; } Secure zero (arrelisted & lt; string & gt; result) on peacxextrack {array adapter & lt; String & gt; ArrayAdapter = New Arrayheader & lt; String & gt; (Main activity. This, Android .Rate. Syple_list_item_1, results); Lv.setAdapter (arrayAdapter); Dialog.dismiss ();   

Help is always appreciated, thanks

edit

  ArrayList & lt; String & gt; Temparrlist = new arreelist & lt; String & gt; (); Temparrlist = listftpitems (); String uri = temparrlist.get (position) .toString (); File file = new file (environment .getExternalStorage directory () .getAbsolutePath () + "/ FtpFiles" + "/" + Yuri); If (uri.endsWith (".pdf") || uri.endsWith (".txt")) {intent object = new intent (intent.ACTION_VIEW); Target.setDataAndType (Uri.fromFile (file), "Applications / PDF"); Target.setFlags (Intent.FLAG_ACTIVITY_NO_HISTORY); Intent = intent to intent Create (target, "open file"); Try {StartActivity}; } Hold (exception e) {toast. MakeApplicationContext, "File not found", 500). Show (); Logs. E ("Error", "" + E); }    

this code ...

  Toast .me text (getApplicationContext (), "clicked", 500);   

should be like this ...

  Toast. Make Text (getApplicationContext (), "Clicked", Toast.LnnGHIHORAT) Show ();   

To show you toast notifications, use show () method

edit: < / P>

You can use the following code to use specific time ..........

  Last Toast toast = Toast. Make text (GetApplicationContext (), "" toast. Elaananacaiacaartia "is clicked on); Toastkshow (); handler handler = new Handler (); handler. Post Dilaatted (new Rnnabl () {@Override public void run ( ) {Toast.cancel ();}}, 500);   

Edit:

Open the following code to use PDF ... This is for me Works ........... but make sure that you have your mobile ............

  btn_open.setOnClickListener (New OnClickListener () {@Override Public Zero onClick (see v) {name = edt_filename PDF Reader. Gettext () toString () ;. // selected file ... File name = new File (Environment.getExternalStorageDirectory () getAbsolutePath () + '/ documents "+" / "+ name +" PDF. Go to the target of the target = new intent (Intent.ACTION_VIEW); target.setDataAndType (Uri.fromFile (file), "application / PDF"); target.setFlags (Intent.FLAG_ACTIVITY_NO_HISTORY); Intent Intent = Intent.createChooser (target, "open file"), {startActivity};} hold (ActivityNotFoundException e) {// direct user to install PDF reader here, or something else}}});    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -