package com.linkifytextdemo;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.app.Activity;
import android.os.Bundle;
import android.text.util.Linkify;
import android.text.util.Linkify.MatchFilter;
import android.text.util.Linkify.TransformFilter;
import android.widget.TextView;
public class LinkifyTextDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_linkify_text_demo); //error
TextView textView = (TextView)findViewById(R.id.txtSampleTextView); //error
textView.setText("This is a demo of custom text linkify, developed by @Pratik");
MatchFilter matchFilter = new MatchFilter() {
public final boolean acceptMatch(CharSequence s, int start, int end) {
// you can compare match over here
// return s.toString().equals("@Pratik");
return true;
}
};
TransformFilter transformFilter = new TransformFilter() {
public final String transformUrl(final Matcher match, String url) {
return "www.google.com";
}
};
Pattern pattern = Pattern.compile("@Bharat");
String scheme = "http://";
Linkify.addLinks(textView, pattern, scheme, matchFilter, transformFilter);
}
}
id cannot be resolved
Page 1 of 16 Replies - 573 Views - Last Post: 16 August 2012 - 05:16 PM
#1
id cannot be resolved
Posted 15 August 2012 - 08:46 AM
Hi, I've been trying the following code and getting two errors "R cannot be resolved". I also imported the package android.R; still didn't work, even cleaned and deleted R.java file but no success.
Replies To: id cannot be resolved
#3
Re: id cannot be resolved
Posted 15 August 2012 - 09:49 AM
There is most likely an error in one of your xml files that is preventing R.java from being generated. If I had to guess its probably in one of your layout files! Post your code for your layout file.
#4
Re: id cannot be resolved
Posted 15 August 2012 - 09:58 AM
H3R3T1C, on 15 August 2012 - 09:49 AM, said:
There is most likely an error in one of your xml files that is preventing R.java from being generated. If I had to guess its probably in one of your layout files! Post your code for your layout file.
R.java file is present. The error is in R.id.txtSampleTextView cannot be resolved.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/txtSampleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/title_activity_linkify_text_demo"
tools:context=".LinkifyTextDemo" />
</RelativeLayout>
#5
Re: id cannot be resolved
Posted 15 August 2012 - 10:00 AM
try removing tools:context=".LinkifyTextDemo" from your layout file.
#6
Re: id cannot be resolved
Posted 16 August 2012 - 05:19 AM
#7
Re: id cannot be resolved
Posted 16 August 2012 - 05:16 PM
You need to make sure you import com.linkifytextdemo.R
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote







|