It's hard to see what's going on here because you didn't post the
outer part -- is this an activity onCreate? Looks like you're
accessing your string field before the setContentView.

This is loosely related to your question but you might consider that:
- you're not supposed to do the network fetching part in the main
thread (you don't want to block it and your app will ANR)
- if you move your code to another thread, you can only access the UI
from the main thread.

You might want to change your operation order: set the content view &
get the views, post a thread that will get the data and update your UI
when done.

R/

On Thu, Apr 16, 2009 at 1:08 PM, murphy <howt...@hotmail.com> wrote:
>
> Hi, I'm trying to use the code below to connect to an online source,
> then compare the data as it is read line by line against what is typed
> in an EditText field before displaying the next page. At the moment
> when I run it and press the "Sign In" button nothing happens. The
> problem seems to be with the comparison of the data. Can anyone help.
>
> try{
>
>                URL myURL = new URL("http://www.donalokeeffe.com/
> usernames.txt");
>
>                URLConnection conn = myURL.openConnection();
>                conn.connect();
>
>                BufferedReader is = new BufferedReader(new InputStreamReader
> (conn.getInputStream(), "UTF-8"));
>
>                String istr;
>                EditText username = (EditText)findViewById(R.id.username2);
>                String usrname = username.getText().toString();
>
>                while ((istr = is.readLine()) != null)
>                {
>                        if(is.readLine() == usrname)
>                        {
>                                setContentView(R.layout.menu);
>
>                        Button button2 = (Button)findViewById(R.id.timetable);
>                    button2.setOnClickListener(mShowttListener);
>
>                    Button button3 = (Button)findViewById(R.id.news);
>                    button3.setOnClickListener(mShowlatnewsListener);
>
>                    Button button4 = (Button)findViewById(R.id.lecturer);
>                    button4.setOnClickListener(mShowlecturerListener);
>
>                    Button logout = (Button)findViewById(R.id.logout);
>                    logout.setOnClickListener(mShowmainListener);
>
>                        }
>                }
>
>                }catch ( IOException e )
>            {
>                Log.d(TAG, "Can not connect to the target server!" );
>                try {
>                                        throw new IOException();
>                                } catch (IOException e1) {
>                                        // TODO Auto-generated catch block
>                                        e1.printStackTrace();
>                                }
>            }
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to