Hi, I am pretty new to programming and just to try Andorid. I am trying to create an simple app that ask after a string from the user and after that I want my program to go out on the internet with the web-browser.
But I get 2 things wrong, one thing is my way to go on the internet but that I know I chose the wrong method, but the other thing is that findViewById(R.id. ) don't work, and I cant understand why..
My code (from http://pastebay.com/77559):
package team.ice.kth;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
public class KTH extends Activity {
private Button mButton;
private EditText mClassInfo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mClassInfo = (EditText) findViewById(R.id.ClassInfo);
final Button mButton = (Button) this.findViewById(R.id.OK_Button);
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
onGoTo();
}
private void onGoTo() {
createUrl();
}
protected void createUrl() {
String Class = mClassInfo.getText().toString();
WebView webview = new WebView(this);
setContentView(webview);
webview.loadUrl("http://schema.sys.kth.se/4DACTION/WebShowSearch/2/1-0?wv_type=5&wv_category=0&wv_ts=20091220T015342X7921&wv_search=" + Class + "&wv_startWeek=935&wv_stopWeek=951&wv_first=0&wv_addObj=&wv_delObj=&wv_obj1=19498000&wv_graphic=Grafiskt+format");
}
});
}
}
and my XML (from http://pastebay.com/77560):
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<EditText
android:id="@+id/class"
android:layout_width="96px"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_x="120px"
android:layout_y="43px" />
<TextView
android:id="@+id/ClassInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Class:"
android:layout_x="62px"
android:layout_y="58px" />
<Button
android:id="@+id/OK_Button"
android:layout_width="47px"
android:layout_height="39px"
android:text="Sök"
android:layout_x="237px"
android:layout_y="52px" />
</AbsoluteLayout>
Would appreciate so I cant get this ghost out of my head, my knowledge cant get me any further.