This is originally a Java code. I tried to convert it for Android. In my XML I have a textbox. The text.setText is supposed to write the output to the textbox, but nothing is appearing.

    private static URL URLObj;
    private static URLConnection connect;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TextView text = new TextView(this);

        try {

            URLObj = new URL("http://students.usls.edu.ph");
            connect = URLObj.openConnection();
            connect.setDoOutput(true);  
        }
        catch (MalformedURLException ex) {
            text.setText("The URL specified was unable to be parsed or uses an invalid protocol. Please try again.");
            System.exit(1); 
        }
        catch (Exception ex) {
            text.setText("An exception occurred. " + ex.getMessage());
            System.exit(1);
        }


        try {

            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(connect.getOutputStream()));
            writer.write("username=0920204&password=183456&submit=Login");
            writer.close();

            BufferedReader reader = new BufferedReader(new InputStreamReader(connect.getInputStream()));

            String lineRead = "";


            while ((lineRead = reader.readLine()) != null) {
                text.setText(lineRead);
            }

            reader.close();
        }
        catch (Exception ex) {
            text.setText("There was an error reading or writing to the URL: " + ex.getMessage());
        }
    }



}

One problem I can see is that you have created the textView in the Java code rather then within main.xml but not added the View to the layout. You czan create widgets in xml or in code (or both) but they need adding to a view group using
this.addContentView(text);
You may also need to add parameters for the widget size.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.