Code is as follows, and i set a breakpoint on certain line(i have marked it in the code below, in fact, Eclipse always tells me "source no found", wherever i set the breakpoint):
package com.app.MainActivity;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.content.res.XmlResourceParser;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class Chapter03_ResourceActivity extends Activity {
/** Called when the activity is first created. */
private Button myButton;
final private TextView myTextView = (TextView)findViewById(R.id.text_xml);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myButton = (Button)findViewById(R.id.btn_xml);
myButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
StringBuilder sb = new StringBuilder(); <==Here breakpoint
XmlResourceParser xrp = getResources().getXml(R.xml.test);
int counter = 0;
try {
while(xrp.getEventType() != XmlPullParser.END_DOCUMENT) {
if(xrp.getEventType() == XmlPullParser.START_TAG) {
String name = xrp.getName();
if(name.equals("customer")) {
counter ++;
sb.append(counter + " Customer" + "\n");
sb.append(xrp.getAttributeValue(0) + "\n");
sb.append(xrp.getAttributeValue(1) + "\n");
sb.append(xrp.getAttributeValue(2) + "\n\n");
}
xrp.next();
}
}
myTextView.setText(sb.toString());
} catch(IOException e) {
e.printStackTrace();
} catch(XmlPullParserException e) {
e.printStackTrace();
}
}
});
}
}
Run--Debug, and then i got a prompt: Source not found. why? cannot Eclipse stop on the breakpoint in the code i supply? why does eclipse need more source code?
Does this help?
Start debugging, and run until you hit a breakpoint
Right click in the Debug view of the Debug perspective (for example on the call stack), and choose "Edit Source Lookup Path"
Add all your projects above "Default", via "Add..." > "Java project" > "Select All"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With