Search Results

Search found 13011 results on 521 pages for 'catch block'.

Page 98/521 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • Exception handling in c#

    - by Lalit
    Hi all, I know how to use try...catch block in c#. Also know why it is using. but what is exact meaning of Exception handling ? see once i write the try {}.. Catch{} i handled null exception then what should happen? what are the standard for exception handling. means what should happen is normally expected if exception occur ?

    Read the article

  • How to Log Exception in a file?

    - by Ismail
    I want to be able to do logging in every catch block. Something like this. catch (Exception exception) { Logger.Write(exception); } and then the settings in the configuration will pick up the Message and StackTrace property etc using customer listener. I would like to use Enterprise Library Logging Application Block. I'm sure someone must have done this already.

    Read the article

  • Write to text file using ArrayList

    - by Ugochukwutubelum Chiemenam
    The program is basically about reading from a text file, storing the current data into an ArrayList, then writing data (from user input) into the same text file. Kindly let me know where I am going wrong in this sub-part? The data inside the text file is as follows: abc t1 1900 xyz t2 1700 The compiler is showing an error at the line output.format("%s%s%s%n", public class justTesting { private Scanner input; private Formatter output; private ArrayList<Student> tk = new ArrayList<Student>(); public static void main(String[] args) { justTesting app = new justTesting(); app.create(); app.writeToFile(); } public void create() { Text entry = new Text(); Scanner input = new Scanner(System.in); System.out.printf("%s\n", "Please enter your name, ID, and year: "); while (input.hasNext()) { try { entry.setName(input.next()); entry.setTelNumber(input.next()); entry.setDOB(input.next()); for (int i = 0; i < tk.size(); i++) { output.format("%s%s%s%n", tk.get(i).getName(), tk.get(i) .getTelNumber(), tk.get(i).getDOB()); } } catch (FormatterClosedException fce) { System.err.println("Error writing to file."); return; } catch (NoSuchElementException nsee) { System.err.println("Invalid input. Try again: "); input.nextLine(); } System.out.printf("%s\n", "Please enter your name, ID, and year: "); } } public void writeToFile() { try { output = new Formatter("testing.txt"); } catch (SecurityException se) { System.err .println("You do not have write access permission to this file."); System.exit(1); } catch (FileNotFoundException fnfe) { System.err.println("Error opening or creating file."); System.exit(1); } } }

    Read the article

  • An error occurred creating the form. See Exception.InnerException for details. The error is: Object

    - by Ben
    I get this error when attempting to debug my form, I cannot see where at all the error could be (also does not highlight where), anyone have any suggestions? An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. Public Class Form1 Dim dateCrap As String = "Date:" Dim IPcrap As String = "Ip:" Dim pcCrap As String = "Computer:" Dim programCrap As String = "Program:" Dim textz As String = TextBox1.Text Dim sep() As String = {vbNewLine & vbNewLine} Dim sections() As String = Text.Split(sep, StringSplitOptions.None) Dim NewArray() As String = TextBox1.Text.Split(vbNewLine) Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click For i = 0 To sections.Count - 1 TextBox2.Text = sections(i) Dim text2 As String = TextBox2.Text Dim sep2() As String = {vbNewLine & vbNewLine} Dim sections2() As String = Text.Split(sep, StringSplitOptions.None) Dim FTPinfo() As String = TextBox2.Text.Split(vbNewLine) Dim clsRequest As System.Net.FtpWebRequest = _ DirectCast(System.Net.WebRequest.Create(sections2(0).Replace("Url/Host:", "")), System.Net.FtpWebRequest) clsRequest.Credentials = New System.Net.NetworkCredential(sections2(1).Replace("Login:", ""), (sections2(2).Replace("Password:", ""))) clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile ' read in file... Dim bFile() As Byte = System.IO.File.ReadAllBytes(txtShellDir.Text) ' upload file... Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream() clsStream.Write(bFile, 0, bFile.Length) clsStream.Close() clsStream.Dispose() Next End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ListBox1.Items.Clear() Dim fdlg As OpenFileDialog = New OpenFileDialog() fdlg.Title = "Browse for the FTP List you wish to use." fdlg.InitialDirectory = Application.ExecutablePath fdlg.Filter = "All files (*.txt)|*.txt|txt files (*.txt)|*.txt" fdlg.FilterIndex = 2 fdlg.RestoreDirectory = True If fdlg.ShowDialog() = DialogResult.OK Then 'ListBox1.Items.AddRange(Split(My.Computer.FileSystem.ReadAllText(fdlg.FileName), vbNewLine)) TextBox1.Text = My.Computer.FileSystem.ReadAllText(fdlg.FileName) End If Dim tmp() As String = TextBox1.Text.Split(CChar(vbNewLine)) For Each line As String In tmp If line.Length > 1 Then TextBox1.AppendText(line & vbNewLine) End If Next TextBox1.Text = TextBox1.Text.Replace(" ", "") TextBox1.Text = TextBox1.Text.Replace("----------------------------------------------------------", vbNewLine) For Each item As String In NewArray ListBox1.Items.Add(item) Next Try For i = 0 To ListBox1.Items.Count - 1 If ListBox1.Items(i).Contains(dateCrap) Then ListBox1.Items.RemoveAt(i) End If Next Catch ex As Exception End Try Try For i = 0 To ListBox1.Items.Count - 1 If ListBox1.Items(i).Contains(IPcrap) Then ListBox1.Items.RemoveAt(i) End If Next Catch ex As Exception End Try Try For i = 0 To ListBox1.Items.Count - 1 If ListBox1.Items(i).Contains(pcCrap) Then ListBox1.Items.RemoveAt(i) End If Next Catch ex As Exception End Try Try For i = 0 To ListBox1.Items.Count - 1 If ListBox1.Items(i).Contains(programCrap) Then ListBox1.Items.RemoveAt(i) End If Next Catch ex As Exception End Try TextBox1.Text = "" For Each thing As Object In ListBox1.Items TextBox1.AppendText(thing.ToString & vbNewLine) Next End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) For i = 0 To ListBox1.SelectedItems.Count - 1 TextBox1.Text = TextBox1.Text & ListBox1.Items.Item(i).ToString() & vbNewLine Next End Sub End Class

    Read the article

  • Sending tweets using Android

    - by Saranya.R
    I want to send a tweet from Android.I have executed the following code.But I am not bale to send any tweets.Avtually the button I created is not working.Can anybody tel me wats the prob? This is my code.. package samplecode.sampleapp.sampletwidgitpublicintent; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.os.Bundle; public class TwidgitPublicIntent extends Activity implements OnClickListener { private static final int TWIDGIT_REQUEST_CODE = 2564; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ((Button)findViewById(R.id.tweet_button)).setOnClickListener(this); ((Button)findViewById(R.id.mention_button)).setOnClickListener(this); ((Button)findViewById(R.id.retweet_button)).setOnClickListener(this); ((Button)findViewById(R.id.message_button)).setOnClickListener(this); } public void onClick(View v) { switch(v.getId()) { case R.id.tweet_button: // Standard tweet Intent tIntent = new Intent("com.disretrospect.twidgit.TWEET"); tIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); try { this.startActivityForResult(tIntent, TWIDGIT_REQUEST_CODE); } catch (ActivityNotFoundException e) { // If Twidgit is not installed } break; case R.id.mention_button: // Mention Intent mIntent = new Intent("com.disretrospect.twidgit.MENTION"); mIntent.putExtra("com.disretrospect.twidgit.extras.TO", "_username_to_xmention_"); mIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); try { this.startActivityForResult(mIntent, TWIDGIT_REQUEST_CODE); } catch (ActivityNotFoundException e) { // If Twidgit is not installed } break; case R.id.retweet_button: // Retweet a tweet Intent rtIntent = new Intent("com.disretrospect.twidgit.RETWEET"); rtIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); rtIntent.putExtra("com.disretrospect.twidgit.extras.VIA", "_original_author_of_tweet_name_"); try { this.startActivityForResult(rtIntent, TWIDGIT_REQUEST_CODE); } catch (ActivityNotFoundException e) { // If Twidgit is not installed } break; case R.id.message_button: // Send DM Intent dmIntent = new Intent("com.disretrospect.twidgit.DIRECT_MESSAGE"); dmIntent.putExtra("com.disretrospect.twidgit.extras.TO", "_username_to_send_dm_to_"); dmIntent.putExtra("com.disretrospect.twidgit.extras.MESSAGE", "_message_in_here_"); try { this.startActivityForResult(dmIntent, TWIDGIT_REQUEST_CODE); } catch (ActivityNotFoundException e) { // If Twidgit is not installed } break; } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Check result code if(resultCode == Activity.RESULT_OK) { // Check requestCode switch(requestCode) { case TWIDGIT_REQUEST_CODE: // Handle successful return break; } } else if(resultCode == Activity.RESULT_CANCELED){ // Handle canceled activity } } }

    Read the article

  • Exceptions from WCF

    - by adrianm
    What exceptions can be thrown from a WCF client? I usually catch CommunicationFaultedException, CommunicationException, TimoutException and some other but from time to time new ones occur, e.g. most recently QuotaExceededException There is no common base to catch (except Exception) so does anyone have a complete list?

    Read the article

  • SQl Server error handling pattern

    - by Patrick Honorez
    Hi all. I am not an expert on SQl Server. Is this a valid pattern for handling errors in a batch of SELECT, INSERT...in SQl SERVER ? (I use v.2008) BEGIN TRANSACTION BEGIN TRY -- statement 1 -- statement 2 -- statement 3 COMMIT TRANSACTION END TRY BEGIN CATCH ROLLBACK TRANSACTION END CATCH Thanks

    Read the article

  • exceptions thrown terminate the script?

    - by fayer
    i wonder if exceptions that are thrown in php will terminate the script in php? cause when i save an entry that is already created in doctrine it throws an exception. i catch the exception and ignore it (so that the user won't see it) but the script seems to be terminated. is there a way to catch the exception and keep the script alive? thanks

    Read the article

  • Why does this vertical-align:middle fails in Jquery mobile

    - by SJ GJ
    Am trying to middle a set of icons to the middle of screen, below is the code: <div data-role="content" class="ui-content ui-body-a" style="vertical-align: middle" data-theme="a"> <fieldset class="ui-grid-a icon-set" style="vertical-align: middle" data-theme="b"> <div class="ui-block-a center" style="vertical-align: middle"> <a href="test"> <div> <img src="css/images/test5.png" style="width: 80px;height: 80px"/> </div> <div> Login </div> </a> </div> <div class="ui-block-b center"> <a href="#settings" data-transition='slide'> <div> <img src="css/images/test4.png" style="width: 80px;height: 80px"/></div> <div>Settings</div> </a> </div> <div class="ui-block-a center"> <a href="test"> <div> <img src="css/images/test2.png" style="width: 80px;height: 80px"/></div> <div>Aboutus</div> </a> </div> <div class="ui-block-b center"> <a href="test"> <div> <img src="css/images/test1.png" style="width: 80px;height: 80px"/></div> <div>Contact Us</div> </a> </div> </fieldset> </div>

    Read the article

  • SwingWorker exceptions lost even when using wrapper classes

    - by Ti Strga
    I've been struggling with the usability problem of SwingWorker eating any exceptions thrown in the background task, for example, described on this SO thread. That thread gives a nice description of the problem, but doesn't discuss recovering the original exception. The applet I've been handed needs to propagate the exception upwards. But I haven't been able to even catch it. I'm using the SimpleSwingWorker wrapper class from this blog entry specifically to try and address this issue. It's a fairly small class but I'll repost it at the end here just for reference. The calling code looks broadly like try { // lots of code here to prepare data, finishing with SpecialDataHelper helper = new SpecialDataHelper(...stuff...); helper.execute(); } catch (Throwable e) { // used "Throwable" here in desperation to try and get // anything at all to match, including unchecked exceptions // // no luck, this code is never ever used :-( } The wrappers: class SpecialDataHelper extends SimpleSwingWorker { public SpecialDataHelper (SpecialData sd) { this.stuff = etc etc etc; } public Void doInBackground() throws Exception { OurCodeThatThrowsACheckedException(this.stuff); return null; } protected void done() { // called only when successful // never reached if there's an error } } The feature of SimpleSwingWorker is that the actual SwingWorker's done()/get() methods are automatically called. This, in theory, rethrows any exceptions that happened in the background. In practice, nothing is ever caught, and I don't even know why. The SimpleSwingWorker class, for reference, and with nothing elided for brevity: import java.util.concurrent.ExecutionException; import javax.swing.SwingWorker; /** * A drop-in replacement for SwingWorker<Void,Void> but will not silently * swallow exceptions during background execution. * * Taken from http://jonathangiles.net/blog/?p=341 with thanks. */ public abstract class SimpleSwingWorker { private final SwingWorker<Void,Void> worker = new SwingWorker<Void,Void>() { @Override protected Void doInBackground() throws Exception { SimpleSwingWorker.this.doInBackground(); return null; } @Override protected void done() { // Exceptions are lost unless get() is called on the // originating thread. We do so here. try { get(); } catch (final InterruptedException ex) { throw new RuntimeException(ex); } catch (final ExecutionException ex) { throw new RuntimeException(ex.getCause()); } SimpleSwingWorker.this.done(); } }; public SimpleSwingWorker() {} protected abstract Void doInBackground() throws Exception; protected abstract void done(); public void execute() { worker.execute(); } }

    Read the article

  • UpdateLayout throwing an ambigious exception

    - by Ouais
    the stack trace displays my method's name then "external code" then app_unhandledexception method, I'm developing within VS2008 SP1 for silverlight on firefox and windows 7(if that makes a difference). the weird thing is, the updatelayout method is called elsewhere and it generates no exception there, that said, if I put the method within a try-catch clause, it doesn't catch the exception, so if anyone has an idea, I'd appreciate it.

    Read the article

  • Java Swing Forms Catching Data

    - by RhigoHR
    Hi everybody, I have a form in swing with a lot of textfields receiving data, then, the idea is when a click on a botton, the app catch all the data from the textfields. Do you know a good practice for this?, or is it necessary to catch textfield by textfield to get the data?.. Thx for your time.

    Read the article

  • Android: Unable to access a local website over HTTPS

    - by user1253789
    I am trying to access a locally hosted website and get its HTML source to parse. I have few questions: 1) Can I use "https://An IP ADDRESS HERE" as a valid URL to try and access. I do not want to make changes in the /etc/hosts file so I want to do it this way. 2) I cannot get the html, since it is giving me Handshake exceptions and Certificate issues. I have tried a lot of help available over the web , but am not successful. Here is the code I am using: public class MainActivity extends Activity { private TextView textView; String response = ""; String finalresponse=""; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView) findViewById(R.id.TextView01); System.setProperty("javax.net.ssl.trustStore","C:\\User\\*" ); System.setProperty("javax.net.ssl.trustStorePassword", "" ); } private class DownloadWebPageTask extends AsyncTask<String, Void, String> { @Override protected String doInBackground(String... urls) { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) { } public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) { } } }; try { SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch (Exception e) { } try { URL url = new URL("https://172.27.224.133"); HttpsURLConnection con =(HttpsURLConnection)url.openConnection(); con.setHostnameVerifier(new AllowAllHostnameVerifier()); finalresponse=readStream(con.getInputStream()); } catch (Exception e) { e.printStackTrace(); } return finalresponse; } private String readStream(InputStream in) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(in)); String line = ""; while ((line = reader.readLine()) != null) { response+=line; } } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } return response; } @Override protected void onPostExecute(String result) { textView.setText(finalresponse); } } public void readWebpage(View view) { DownloadWebPageTask task = new DownloadWebPageTask(); task.execute(new String[] { "https://172.27.224.133" }); } }

    Read the article

  • How solve consumer/producer task using semaphores

    - by user1074896
    I have SimpleProducerConsumer class that illustrate consumer/producer problem (I am not sure that it's correct). public class SimpleProducerConsumer { private Stack<Object> stack = new Stack<Object>(); private static final int STACK_MAX_SIZE = 10; public static void main(String[] args) { SimpleProducerConsumer pc = new SimpleProducerConsumer(); new Thread(pc.new Producer(), "p1").start(); new Thread(pc.new Producer(), "p2").start(); new Thread(pc.new Consumer(), "c1").start(); new Thread(pc.new Consumer(), "c2").start(); new Thread(pc.new Consumer(), "c3").start(); } public synchronized void push(Object d) { while (stack.size() >= STACK_MAX_SIZE) try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } stack.push(new Object()); System.out.println("push " + Thread.currentThread().getName() + " " + stack.size()); notify(); } public synchronized Object pop() { while (stack.size() == 0) try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } stack.pop(); System.out.println("pop " + Thread.currentThread().getName() + " " + stack.size()); notify(); return null; } class Consumer implements Runnable { @Override public void run() { while (true) { pop(); } } } class Producer implements Runnable { @Override public void run() { while (true) { push(new Object()); } } } } I found simple realization of semaphore(here:http://docs.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html I know that there is concurrency package) How I need to change code to exchange java objects monitors to my custom semaphore. (To illustrate C/P problem using semaphores) Semaphore: class Semaphore { private int counter; public Semaphore() { this(0); } public Semaphore(int i) { if (i < 0) throw new IllegalArgumentException(i + " < 0"); counter = i; } public synchronized void release() { if (counter == 0) { notify(); } counter++; } public synchronized void acquire() throws InterruptedException { while (counter == 0) { wait(); } counter--; } }

    Read the article

  • Find UI components in real time run, under Android OS, it is possible?

    - by kimo
    Hi All, I want to know if I can find/reach UI components of running application under Android OS. it is possible to catch the Button/DDL/.. that was clicked by the user in real-time, example from other subject(web): In browser I can listen to the events and catch the DOM object that was clicked, in this way I can save the DOM object data. catching UI components that was changed by the user will give the option to save UI componentdata, and to perform the user actions automatic. Thanks.

    Read the article

  • Debugging asp.net suddenly stops

    - by Lieven Cardoen
    I have a strange error. I'm debugging an asp.net site and suddenly it stops. Visual Studio stays in debug mode and my web application stays on running just fine. I found this post on, but I don't think a background thread is causing the problem. There's even a try catch around the code where it usually stops debugging, but the catch is not triggered... Everytime I try it, it stops at a different place in the code.

    Read the article

  • Scope of const char*

    - by Neeraj
    Consider this code: const char* someFun() { // ... some stuff return "Some text!!" } int main() { { // Block: A const char* retStr = someFun(); // use retStr } } My question is in the function sumFun() where is "some Text!!", stored (i think may be in some static area in ROM) and what will be its scope? Will the memory pointed by retStr be occupied throughout the program or be released once the block A exits? -- Thanks

    Read the article

  • Javascript variables

    - by Uli
    I'm learning Javascript right now. Can anybody tell me why the second code block traces a empty path for -launch(this)- but using the first code block it gives me the right path? "<form action='"+launchwebsite+"/subsite/' method='post' target='_blank' onsubmit='launch(this)'>" and this not: "<a onclick='launch(this)' title='launch' class='iblack' /></a></div>" Best Uli

    Read the article

  • Asp.Net MVC Error Handling & logging

    - by Navish Rampal
    I am trying to Catch exceptions and log it. Presently I have written a Utility method and Passing the Exception to it in the catch block and finally logging the application using MS Enterprise Library 4.0. I want to know is there any other better way to log errors. Show exception message in the same view for some type of exceptions for rest navigate to error page. If someone can help me on this! Navish

    Read the article

  • How to set message when I get Exception

    - by user1748932
    public class XMLParser { // constructor public XMLParser() { } public String getXmlFromUrl(String url) { String responseBody = null; getset d1 = new getset(); String d = d1.getData(); // text String y = d1.getYear(); // year String c = d1.getCircular(); String p = d1.getPage(); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("YearID", y)); nameValuePairs.add(new BasicNameValuePair("CircularNo", c)); nameValuePairs.add(new BasicNameValuePair("SearchText", d)); nameValuePairs.add(new BasicNameValuePair("pagenumber", p)); try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); responseBody = EntityUtils.toString(entity); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // return XML return responseBody; } public Document getDomElement(String xml) { Document doc = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(xml)); doc = db.parse(is); } catch (ParserConfigurationException e) { Log.e("Error: ", e.getMessage()); return null; } catch (SAXException e) { Log.e("Error: ", e.getMessage()); // i m getting Exception here return null; } catch (IOException e) { Log.e("Error: ", e.getMessage()); return null; } return doc; } /** * Getting node value * * @param elem * element */ public final String getElementValue(Node elem) { Node child; if (elem != null) { if (elem.hasChildNodes()) { for (child = elem.getFirstChild(); child != null; child = child .getNextSibling()) { if (child.getNodeType() == Node.TEXT_NODE) { return child.getNodeValue(); } } } } return ""; } /** * Getting node value * * @param Element * node * @param key * string * */ public String getValue(Element item, String str) { NodeList n = item.getElementsByTagName(str); return this.getElementValue(n.item(0)); } } I am getting Exception in this class for parsing data. I want print this message in another class which extends from Activity. Can you please tell me how? I tried much but not able to do.. public class AndroidXMLParsingActivity extends Activity { public int currentPage = 1; public ListView lisView1; static final String KEY_ITEM = "docdetails"; static final String KEY_NAME = "heading"; public Button btnNext; public Button btnPre; public static String url = "http://dev.taxmann.com/TaxmannService/TaxmannService.asmx/GetNotificationList"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // listView1 lisView1 = (ListView) findViewById(R.id.listView1); // Next btnNext = (Button) findViewById(R.id.btnNext); // Perform action on click btnNext.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { currentPage = currentPage + 1; ShowData(); } }); // Previous btnPre = (Button) findViewById(R.id.btnPre); // Perform action on click btnPre.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { currentPage = currentPage - 1; ShowData(); } }); ShowData(); } public void ShowData() { XMLParser parser = new XMLParser(); String xml = parser.getXmlFromUrl(url); // getting XML Document doc = parser.getDomElement(xml); // getting DOM element NodeList nl = doc.getElementsByTagName(KEY_ITEM); int displayPerPage = 5; // Per Page int TotalRows = nl.getLength(); int indexRowStart = ((displayPerPage * currentPage) - displayPerPage); int TotalPage = 0; if (TotalRows <= displayPerPage) { TotalPage = 1; } else if ((TotalRows % displayPerPage) == 0) { TotalPage = (TotalRows / displayPerPage); } else { TotalPage = (TotalRows / displayPerPage) + 1; // 7 TotalPage = (int) TotalPage; // 7 } int indexRowEnd = displayPerPage * currentPage; // 5 if (indexRowEnd > TotalRows) { indexRowEnd = TotalRows; } // Disabled Button Next if (currentPage >= TotalPage) { btnNext.setEnabled(false); } else { btnNext.setEnabled(true); } // Disabled Button Previos if (currentPage <= 1) { btnPre.setEnabled(false); } else { btnPre.setEnabled(true); } // Load Data from Index int RowID = 1; ArrayList<HashMap<String, String>> menuItems = new ArrayList<HashMap<String, String>>(); HashMap<String, String> map; // RowID if (currentPage > 1) { RowID = (displayPerPage * (currentPage - 1)) + 1; } for (int i = indexRowStart; i < indexRowEnd; i++) { Element e = (Element) nl.item(i); // adding each child node to HashMap key => value map = new HashMap<String, String>(); map.put("RowID", String.valueOf(RowID)); map.put(KEY_NAME, parser.getValue(e, KEY_NAME)); // adding HashList to ArrayList menuItems.add(map); RowID = RowID + 1; } SimpleAdapter sAdap; sAdap = new SimpleAdapter(AndroidXMLParsingActivity.this, menuItems, R.layout.list_item, new String[] { "RowID", KEY_NAME }, new int[] { R.id.ColRowID, R.id.ColName }); lisView1.setAdapter(sAdap); } } This my class where I want to Print that message

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >