hi,
i have written an code for
pattern matching in android. there is no compilation or run time error. i have a
string like this " hi how are you" and if it matches it should display the same output. but i am not getting the result alone. can any one tell where i have missed some statement it would be of great help indeed.
code is
package com.example.android.pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class PatternActivity extends Activity {
TextView tt;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
{
String raw_string = ("hi how are you");
Pattern p = Pattern.compile("hi how are you");
Matcher m = p.matcher(raw_string);
if (m.find()){
String res = m.toMatchResult().group(0);
tt = setText(res.toString());
}
}
private TextView setText(String res) {
// TODO Auto-generated method stub
return null;
}
}
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<Button android:layout_width="wrap_content"
android:id="@+id/calculate"
android:layout_x="41dip"
android:layout_height="wrap_content"
android:text="Calculate"
android:layout_y="232dip"></Button>
<EditText android:text=""
android:layout_width="wrap_content"
android:layout_x="172dip"
android:id="@+id/tt"
android:layout_height="wrap_content"
android:layout_y="232dip"></EditText>
</LinearLayout>
can any one tell what is the error. i have attached the emulator link here