i am trying to download a .txt file from internet and then read it and execute it.
i had success in downloading, reading and executing a single line query file.
but the problem is i cant execute multi line query from the file. i did some research and they did not suit my needs so i came up with a solution but i cant figure out some errors.
my idea is to convert a .txt file, line by line to a List and then for each String in the List execute a query within sqlite.
here's some of my code :
public void updateDB(View v){
new DownloadFileFromURL().execute(file_url);
File file = new File(Environment
.getExternalStorageDirectory().toString()
+ "/update.txt")
Log.i("UPDATE", "SQL DOWNLOADED");
while(start.equals(true)){
List<String> list = readUpdate2("update.txt");
for (String string : list) {
datasource.executeRaw(string);
Log.i("UPDATE", "EXEC SQL # : " + list.size());
}
file.delete();}}
public List<String> readUpdate2(String url){
File sdcard = Environment.getExternalStorageDirectory();
//Get the text file
List<String> list = null;
File file = new File(sdcard,url);
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while((line = br.readLine()) != null) {
// this is where the error happens :
list.add(line);
Log.i("UPDATE", "LINE : " + line);
}
}
catch (IOException e) {
}
return list;
}
the problem is i am stuck with a Nullpointer exception. it says the line is empty.
Here is the logcat :
03-30 18:01:18.965: E/AndroidRuntime(12474): FATAL EXCEPTION: main
03-30 18:01:18.965: E/AndroidRuntime(12474): java.lang.IllegalStateException: Could not execute method of the activity
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.view.View$1.onClick(View.java:3838)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.view.View.performClick(View.java:4475)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.view.View$PerformClick.run(View.java:18786)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.os.Handler.handleCallback(Handler.java:730)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.os.Looper.loop(Looper.java:137)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.app.ActivityThread.main(ActivityThread.java:5493)
03-30 18:01:18.965: E/AndroidRuntime(12474): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 18:01:18.965: E/AndroidRuntime(12474): at java.lang.reflect.Method.invoke(Method.java:525)
03-30 18:01:18.965: E/AndroidRuntime(12474): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
03-30 18:01:18.965: E/AndroidRuntime(12474): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
03-30 18:01:18.965: E/AndroidRuntime(12474): at dalvik.system.NativeStart.main(Native Method)
03-30 18:01:18.965: E/AndroidRuntime(12474): Caused by: java.lang.reflect.InvocationTargetException
03-30 18:01:18.965: E/AndroidRuntime(12474): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 18:01:18.965: E/AndroidRuntime(12474): at java.lang.reflect.Method.invoke(Method.java:525)
03-30 18:01:18.965: E/AndroidRuntime(12474): at android.view.View$1.onClick(View.java:3833)
03-30 18:01:18.965: E/AndroidRuntime(12474): ... 11 more
03-30 18:01:18.965: E/AndroidRuntime(12474): Caused by: java.lang.NullPointerException
03-30 18:01:18.965: E/AndroidRuntime(12474): at com.meemarbashi.meemardictionary.UpdateActivity.readUpdate2(UpdateActivity.java:292)
03-30 18:01:18.965: E/AndroidRuntime(12474): at com.meemarbashi.meemardictionary.UpdateActivity.updateDB(UpdateActivity.java:223)
03-30 18:01:18.965: E/AndroidRuntime(12474): ... 14 more
so basically i am getting no text from the .txt file and then i cannot add anything to my List. what should i do ?
thanks in advance
This is probably the reason of null pointer exception:
List<String> list = null;
Try assigning a new list instead of null
Related
everything is mainly explained in the title ill go in as much detail as i can. I am making an android game app i created a unique id for a circle that is drawn in canvas in the DrawingView class since this cannot be referenced in xml i had to create the id as an int in java so that java could find the id and use it as the button. Im sure you are all very confused by now i will continue will putting in my best effort to explain. below is the code for the Main file that gets called
public class Main extends Activity {
DrawingView v;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
LinearLayout layout1 = new LinearLayout (this);
FrameLayout game = new FrameLayout(this);
DrawingView v = new DrawingView (this);
TextView myText = new TextView(this);
int w = getResources().getInteger(DrawingView.redColor);
Button redCircle = (Button) findViewById(w);
redCircle.setWidth(300);
redCircle.setText("Start Game");
layout1.addView(myText);
layout1.addView(redCircle);
//redCircle.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
game.addView(v);
game.addView(layout1);
setContentView(game);
redCircle.setOnClickListener((OnClickListener) this);
}
public void onClick(View v) {
Intent intent = new Intent(this, Main.class);
startActivity(intent);
// re-starts this activity from game-view. add this.finish(); to remove from stack
}
#Override
public boolean onCreateOptionsMenu(Menu menu){
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
and not really neccessary but to help you understand what i am trying to accomplish here is the DrawingView class that creates random circles either green or red below.
public class DrawingView extends View {
public DrawingView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
RectF rectf = new RectF(0, 0, 200, 0);
private static final int w = 100;
public static int lastColor = Color.BLACK;
private final Random random = new Random();
private final Paint paint = new Paint();
private final int radius = 230;
private final Handler handler = new Handler();
public static int redColor = Color.RED;
public static int greenColor = Color.GREEN;
private final Runnable updateCircle = new Runnable() {
#Override
public void run() {
lastColor = random.nextInt(2) == 1 ? redColor : greenColor;
paint.setColor(lastColor);
invalidate();
handler.postDelayed(this, 1000);
}
};
#Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
handler.post(updateCircle);
}
#Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
handler.removeCallbacks(updateCircle);
}
#Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// your other stuff here
canvas.drawCircle(random.nextInt(canvas.getWidth()-radius/2) + radius/2f, random.nextInt(canvas.getHeight()-radius/2) + radius/2f, radius, paint);
}
//Bitmap.Config conf = Bitmap.Config.ARGB_8888; // see other conf types
//private int h = 100;
//#SuppressLint("DrawAllocation")
//Bitmap bmp = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap
//Canvas canvas = new Canvas(bmp);
/*
private Object canvas(Bitmap bmp) {
// TODO Auto-generated method stub
return null;
}
*/
}
and more importantly the log cat errors that display after the app crashes
03-30 02:27:27.903: E/AndroidRuntime(3104): FATAL EXCEPTION: main
03-30 02:27:27.903: E/AndroidRuntime(3104): Process: com.Tripps.thesimplegame, PID: 3104
03-30 02:27:27.903: E/AndroidRuntime(3104): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
03-30 02:27:27.903: E/AndroidRuntime(3104): at com.Tripps.thesimplegame.DrawingView.onDraw(DrawingView.java:67)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.draw(View.java:15114)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.updateDisplayListIfDirty(View.java:14048)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.getDisplayList(View.java:14071)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.draw(View.java:14838)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.updateDisplayListIfDirty(View.java:14043)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.getDisplayList(View.java:14071)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.draw(View.java:14838)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.updateDisplayListIfDirty(View.java:14043)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.getDisplayList(View.java:14071)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.draw(View.java:14838)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.updateDisplayListIfDirty(View.java:14043)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.getDisplayList(View.java:14071)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.draw(View.java:14838)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.drawChild(ViewGroup.java:3404)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.draw(View.java:15117)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.widget.FrameLayout.draw(FrameLayout.java:592)
03-30 02:27:27.903: E/AndroidRuntime(3104): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2595)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.updateDisplayListIfDirty(View.java:14048)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.View.getDisplayList(View.java:14071)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:266)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:272)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:311)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2492)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2337)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1968)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.Choreographer.doCallbacks(Choreographer.java:580)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.Choreographer.doFrame(Choreographer.java:550)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.os.Handler.handleCallback(Handler.java:739)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.os.Handler.dispatchMessage(Handler.java:95)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.os.Looper.loop(Looper.java:135)
03-30 02:27:27.903: E/AndroidRuntime(3104): at android.app.ActivityThread.main(ActivityThread.java:5221)
03-30 02:27:27.903: E/AndroidRuntime(3104): at java.lang.reflect.Method.invoke(Native Method)
03-30 02:27:27.903: E/AndroidRuntime(3104): at java.lang.reflect.Method.invoke(Method.java:372)
03-30 02:27:27.903: E/AndroidRuntime(3104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
03-30 02:27:27.903: E/AndroidRuntime(3104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-30 02:38:46.269: D/OpenGLRenderer(3167): Render dirty regions requested: true
03-30 02:38:46.276: D/(3167): HostConnection::get() New Host Connection established 0xae0add60, tid 3167
03-30 02:38:46.287: D/Atlas(3167): Validating map...
03-30 02:38:46.379: D/(3167): HostConnection::get() New Host Connection established 0xa6c52140, tid 3182
03-30 02:38:46.427: I/OpenGLRenderer(3167): Initialized EGL, version 1.4
03-30 02:38:46.473: D/OpenGLRenderer(3167): Enabling debug mode 0
03-30 02:38:46.550: W/EGL_emulation(3167): eglSurfaceAttrib not implemented
03-30 02:38:46.550: W/OpenGLRenderer(3167): Failed to set EGL_SWAP_BEHAVIOR on surface 0xae0ed4a0, error=EGL_SUCCESS
03-30 03:01:54.523: W/ResourceType(3228): No known package when getting value for resource number 0xffff0000
03-30 03:01:54.523: D/AndroidRuntime(3228): Shutting down VM
03-30 03:01:54.524: E/AndroidRuntime(3228): FATAL EXCEPTION: main
03-30 03:01:54.524: E/AndroidRuntime(3228): Process: com.Tripps.thesimplegame, PID: 3228
03-30 03:01:54.524: E/AndroidRuntime(3228): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Tripps.thesimplegame/com.Tripps.thesimplegame.Main}: android.content.res.Resources$NotFoundException: Resource ID #0xffff0000
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.ActivityThread.access$800(ActivityThread.java:144)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.os.Handler.dispatchMessage(Handler.java:102)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.os.Looper.loop(Looper.java:135)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.ActivityThread.main(ActivityThread.java:5221)
03-30 03:01:54.524: E/AndroidRuntime(3228): at java.lang.reflect.Method.invoke(Native Method)
03-30 03:01:54.524: E/AndroidRuntime(3228): at java.lang.reflect.Method.invoke(Method.java:372)
03-30 03:01:54.524: E/AndroidRuntime(3228): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
03-30 03:01:54.524: E/AndroidRuntime(3228): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-30 03:01:54.524: E/AndroidRuntime(3228): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xffff0000
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.content.res.Resources.getValue(Resources.java:1233)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.content.res.Resources.getInteger(Resources.java:989)
03-30 03:01:54.524: E/AndroidRuntime(3228): at com.Tripps.thesimplegame.Main.onCreate(Main.java:34)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.Activity.performCreate(Activity.java:5933)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
03-30 03:01:54.524: E/AndroidRuntime(3228): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
03-30 03:01:54.524: E/AndroidRuntime(3228): ... 10 more
03-30 03:03:04.088: W/ResourceType(3288): No known package when getting value for resource number 0xffff0000
03-30 03:03:04.089: D/AndroidRuntime(3288): Shutting down VM
03-30 03:03:04.089: E/AndroidRuntime(3288): FATAL EXCEPTION: main
03-30 03:03:04.089: E/AndroidRuntime(3288): Process: com.Tripps.thesimplegame, PID: 3288
03-30 03:03:04.089: E/AndroidRuntime(3288): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Tripps.thesimplegame/com.Tripps.thesimplegame.Main}: android.content.res.Resources$NotFoundException: Resource ID #0xffff0000
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.ActivityThread.access$800(ActivityThread.java:144)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.os.Handler.dispatchMessage(Handler.java:102)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.os.Looper.loop(Looper.java:135)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.ActivityThread.main(ActivityThread.java:5221)
03-30 03:03:04.089: E/AndroidRuntime(3288): at java.lang.reflect.Method.invoke(Native Method)
03-30 03:03:04.089: E/AndroidRuntime(3288): at java.lang.reflect.Method.invoke(Method.java:372)
03-30 03:03:04.089: E/AndroidRuntime(3288): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
03-30 03:03:04.089: E/AndroidRuntime(3288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
03-30 03:03:04.089: E/AndroidRuntime(3288): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xffff0000
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.content.res.Resources.getValue(Resources.java:1233)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.content.res.Resources.getInteger(Resources.java:989)
03-30 03:03:04.089: E/AndroidRuntime(3288): at com.Tripps.thesimplegame.Main.onCreate(Main.java:34)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.Activity.performCreate(Activity.java:5933)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
03-30 03:03:04.089: E/AndroidRuntime(3288): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
03-30 03:03:04.089: E/AndroidRuntime(3288): ... 10 more
03-30 03:03:34.502: I/Process(3288): Sending signal. PID: 3288 SIG: 9
You are getting error at :
canvas.drawCircle(random.nextInt(canvas.getWidth()-radius/2) + radius/2f, random.nextInt(canvas.getHeight()-radius/2) + radius/2f, radius, paint);
Because the Object canvas do not have width or height (it is null)
Reason :
Your code adds views like :
LinearLayout layout1 = new LinearLayout (this);
FrameLayout game = new FrameLayout(this);
DrawingView v = new DrawingView (this);
TextView myText = new TextView(this);
int w = getResources().getInteger(DrawingView.redColor);
Button redCircle = (Button) findViewById(w);
redCircle.setWidth(300);
redCircle.setText("Start Game");
layout1.addView(myText);
layout1.addView(redCircle);
//redCircle.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
game.addView(v);
game.addView(layout1);
But at the time of
game.addView(v);
v do not have any views referenced so the null object view is added in
game
So pls add some view i.e. Text or Images in v first and then call
game.addView(v);
This is solution for your error
I've been trying to get my list view to work for quite some time now, I just changed my listener from onClick to onItemClick to handle listview items better but the app crashes once again, my code below, any help would be appreciated.
Class:
public class ListViewAdapterProduct extends BaseAdapter {
Context mContext;
ListView listView = (ListView) findViewById(R.id.listview1);
listView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id){
Resources res = mContext.getResources();
productTitleArray = res.getStringArray(R.array.titles_product);
for (String productTitle : productTitleArray)
{
if(productTitle.equals("productOne"))
{
Log.d("Msg", "Found");
}
else
{
Log.d("Msg", "Not Found");
}
}
}
});
My previous post:
Compare XML String From Java Class When Item In ListView Is Clicked
Logcat:
03-30 16:40:39.027: E/AndroidRuntime(811): FATAL EXCEPTION: main
03-30 16:40:39.027: E/AndroidRuntime(811): java.lang.NullPointerException
03-30 16:40:39.027: E/AndroidRuntime(811): at com.twostarii.test.ListViewAdapterproduct.getView(ListViewAdapterproduct.java:91)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.ListView.makeAndAddView(ListView.java:1831)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.ListView.fillDown(ListView.java:674)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.ListView.fillFromTop(ListView.java:735)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.ListView.layoutChildren(ListView.java:1652)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.AbsListView.onLayout(AbsListView.java:1994)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.View.layout(View.java:14008)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewGroup.layout(ViewGroup.java:4373)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.View.layout(View.java:14008)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewGroup.layout(ViewGroup.java:4373)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.View.layout(View.java:14008)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewGroup.layout(ViewGroup.java:4373)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.View.layout(View.java:14008)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewGroup.layout(ViewGroup.java:4373)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.View.layout(View.java:14008)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewGroup.layout(ViewGroup.java:4373)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.Choreographer.doFrame(Choreographer.java:532)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.os.Handler.handleCallback(Handler.java:725)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.os.Handler.dispatchMessage(Handler.java:92)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.os.Looper.loop(Looper.java:137)
03-30 16:40:39.027: E/AndroidRuntime(811): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-30 16:40:39.027: E/AndroidRuntime(811): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 16:40:39.027: E/AndroidRuntime(811): at java.lang.reflect.Method.invoke(Method.java:511)
03-30 16:40:39.027: E/AndroidRuntime(811): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-30 16:40:39.027: E/AndroidRuntime(811): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-30 16:40:39.027: E/AndroidRuntime(811): at dalvik.system.NativeStart.main(Native Method)
Activity:
public class MainActivityproduct extends MainActivity {
ListView list;
ListViewAdapterproduct adapter;
EditText editsearch;
String[] position;
String[] productTitles;
String[] productDescriptions;
int[] images={
R.drawable.list_product_one,
R.drawable.list_product_two,
R.drawable.list_product_three,
};
ArrayList<ClassproductList> arraylist = new ArrayList<ClassproductList>();
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
position = new String[] { "1", "2", "3"};
Resources res = getResources();
productTitles = res.getStringArray(R.array.titles_product);
productDescriptions = res.getStringArray(R.array.descriptions_product);
list = (ListView) findViewById(R.id.listview1);
list.setAdapter(adapter);
for (int i = 0; i < position.length; i++)
{
ClassproductList wp = new ClassproductList(productTitles[i], productDescriptions[i],images[i]);
arraylist.add(wp);
}
adapter = new ListViewAdapterproduct(this, arraylist);
list.setAdapter(adapter);
editsearch = (EditText) findViewById(R.id.search);
editsearch.addTextChangedListener(new TextWatcher() {
#Override
public void afterTextChanged(Editable arg0) {
String text = editsearch.getText().toString().toLowerCase(Locale.getDefault());
adapter.filter(text);
}
#Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
}
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
You have declared the mContext, but you have not initialized it.
You can do this in the constructor of your adapter:
public class ListViewAdapterProduct extends BaseAdapter {
Context mContext;
// the construcor that initializes the context
public ListViewAdapterProduct(Context c){
mContext = c;
}
...
However, the trace that you have posted, suggest that the problem is in your adapter's getView() method, on line 91. You should check that also.
ListViewAdapterproduct.getView(ListViewAdapterproduct.java:91)
Edit:
list.setAdapter(adapter);
In this line the adapter is null, you did not initialize it... (you set your adapter twice, first with null).
It is a good practise to define your variables locally, and make them class variable only when you actually need it. This way its harder to forget about initialization.
you have a problem in Context mContext; is null
in your activity set mContext = this; so mContext would be the activity context you will be able to use the resources
this is the correct code :
since your already sent this in your adapter you need to catch it there
public class ListViewAdapterProduct extends BaseAdapter {
Context mContext;
ArrayList<ClassproductList> arraylist;
ListView listView = (ListView) findViewById(R.id.listview1);
//add this
public ListViewAdapterProduct (Context mContext,ArrayList<ClassproductList> arraylist)
{
this.mContext = mContext;
this.arraylist = arraylist;
}
SOLVED !!!
I changed back from onItemClick (complicated to use with custom adapter) to onClick (simple to use with custom adapter) and applied:
view.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
String mytitle=holder.title.getText().toString();
if(mytitle.equals("ProductOne")){
Intent intent1 = new Intent(mContext, ProductClass.ProductOne);
mContext.startActivity(intent1);
...
}
}
Had to add:
String mytitle=holder.title.getText().toString();
Hi could someone advise me on whats wrong with the following code. The logcat says its in the onCreate method. all seems to be correct in the mainactivity as i have passed the bundle with the string.
#SuppressLint("NewApi")
public class CurrentBookingFragment extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater,ViewGroup container, Bundle savedInstanceState) {
View view =inflater.inflate(R.layout.current_booking_fragment, container, false);
Bundle bundle = this.getArguments();
String strtext = this.getArguments().getString("GetStringPUFirstLine");
TextView CurrentBookingFragmentTV = (TextView)view.findViewById(R.id.CurrentBookingFragmentTV);
CurrentBookingFragmentTV.setText(strtext);
return view;
}
}
Here is the log:
03-30 21:59:30.385: E/AndroidRuntime(30843): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
03-30 21:59:30.385: E/AndroidRuntime(30843): at dalvik.system.NativeStart.main(Native Method)
03-30 21:59:30.385: E/AndroidRuntime(30843): Caused by: android.view.InflateException: Binary XML file line #45: Error inflating class fragment
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
03-30 21:59:30.385: E/AndroidRuntime(30843): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.Activity.setContentView(Activity.java:1956)
03-30 21:59:30.385: E/AndroidRuntime(30843): at com.example.prototype.MainActivity.onCreate(MainActivity.java:88)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.Activity.performCreate(Activity.java:5372)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
03-30 21:59:30.385: E/AndroidRuntime(30843): ... 11 more
03-30 21:59:30.385: E/AndroidRuntime(30843): Caused by: java.lang.NullPointerException
03-30 21:59:30.385: E/AndroidRuntime(30843): at com.example.prototype.CurrentBookingFragment.onCreateView(CurrentBookingFragment.java:49)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.Fragment.performCreateView(Fragment.java:1699)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:879)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1155)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.app.Activity.onCreateView(Activity.java:4966)
03-30 21:59:30.385: E/AndroidRuntime(30843): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
03-30 21:59:30.385: E/AndroidRuntime(30843): ... 21 more
Creating the fragment:
Fragment CurrentBookingFragment;
CurrentBookingFragment = new CurrentBookingFragment();
FragmentManager fm = getFragmentManager();
Bundle bundle=new Bundle();
bundle.putString("GetStringPUFirstLine", "GetStringPUFirstLine");
CurrentBookingFragment.setArguments(bundle);
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(R.id.BookingFragment, CurrentBookingFragment);
fragmentTransaction.commit();
Try setting the text in onActivityCreated(){}.
#Override
public void onActivityCreated(Bundle savedInstanceState)
{
TextView CurrentBookingFragmentTV = (TextView)view.findViewById(R.id.CurrentBookingFragmentTV);
CurrentBookingFragmentTV.setText(strtext);
}
I am building a complex application however I am having an isolated problem. My Android application class UserPage.java should be able to fetch a String from a webpage and then pass that over to the layout and display it accordingly.
UserPage.java
package com.example.ams;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
public class UserPage extends Activity {
HttpPost httppost;
StringBuffer buffer;
HttpResponse response;
HttpClient httpclient;
List<NameValuePair> nameValuePairs;
ProgressDialog dialog = null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.userpage);
String json = getStudents();
//System.out.println(json);
TextView datazer = (TextView) findViewById(R.id.data);
datazer.setText(json);
}
public String getStudents(){
HttpResponse response = null;
//String classID = "CSD2334";
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI("http://localhost:8080/de.vogella.jersey.first/resources/hello/ids/CSD2334"));
response = client.execute(request);
System.out.println(response.toString());
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response.toString();
}
}
The layout - userpage.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
The content fetched from the web
[{"student_id":3,"student_name":"Dite Gashi","w1mo":"1","w1tue":"0","w1wed":0,"w1thu":0,"w1fri":1},{"student_id":4,"student_name":"Vullnet Dyla","w1mo":"2","w1tue":"2","w1wed":1,"w1thu":0,"w1fri":0},{"student_id":5,"student_name":"Edon Ymeri","w1mo":"0","w1tue":"0","w1wed":0,"w1thu":0,"w1fri":2},{"student_id":6,"student_name":"Ilir Kelmendi","w1mo":"2","w1tue":"0","w1wed":2,"w1thu":0,"w1fri":0}]
The error I am getting is quite generic and I can't seem to find information anywhere
03-30 17:36:15.074: E/AndroidRuntime(1458): FATAL EXCEPTION: main
03-30 17:36:15.074: E/AndroidRuntime(1458): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ams/com.example.ams.UserPage}: android.os.NetworkOnMainThreadException
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.os.Handler.dispatchMessage(Handler.java:99)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.os.Looper.loop(Looper.java:137)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-30 17:36:15.074: E/AndroidRuntime(1458): at java.lang.reflect.Method.invokeNative(Native Method)
03-30 17:36:15.074: E/AndroidRuntime(1458): at java.lang.reflect.Method.invoke(Method.java:511)
03-30 17:36:15.074: E/AndroidRuntime(1458): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-30 17:36:15.074: E/AndroidRuntime(1458): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-30 17:36:15.074: E/AndroidRuntime(1458): at dalvik.system.NativeStart.main(Native Method)
03-30 17:36:15.074: E/AndroidRuntime(1458): Caused by: android.os.NetworkOnMainThreadException
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
03-30 17:36:15.074: E/AndroidRuntime(1458): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
03-30 17:36:15.074: E/AndroidRuntime(1458): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
03-30 17:36:15.074: E/AndroidRuntime(1458): at java.net.InetAddress.getAllByName(InetAddress.java:220)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-30 17:36:15.074: E/AndroidRuntime(1458): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
03-30 17:36:15.074: E/AndroidRuntime(1458): at com.example.ams.UserPage.getStudents(UserPage.java:44)
03-30 17:36:15.074: E/AndroidRuntime(1458): at com.example.ams.UserPage.onCreate(UserPage.java:31)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.Activity.performCreate(Activity.java:4465)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-30 17:36:15.074: E/AndroidRuntime(1458): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-30 17:36:15.074: E/AndroidRuntime(1458): ... 11 more
03-30 17:36:15.363: I/dalvikvm(1458): threadid=3: reacting to signal 3
03-30 17:36:15.434: I/dalvikvm(1458): Wrote stack traces to '/data/anr/traces.txt'
03-30 17:36:15.814: I/dalvikvm(1458): threadid=3: reacting to signal 3
03-30 17:36:15.834: I/dalvikvm(1458): Wrote stack traces to '/data/anr/traces.txt'
Any help or pointers would be highly appreciated,
D
You are running a http call on the main thread and that causes the error.
response = client.execute(request);
The above code should run on a new Thread.
Your should have something like:
new Thread( new Runnable() {
#Override
public void run() {
HttpResponse response = null;
//String classID = "CSD2334";
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI("http://localhost:8080/de.vogella.jersey.first/resources/hello/ids/CSD2334"));
response = client.execute(request);
System.out.println(response.toString());
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response.toString();
}
}).start();
And if you want to make updates to a UI component you should run the code into:
runOnUiThread(new Runnable() {
#Override
public void run() {
// runs on the UI thread so update UI here
}
});
You should read more about threads on android
Your current code runs, as mentioned, on the uiThread. Consider using either an asynctask or a class which extends Thread. There is a lot of questions regarding this, by doing a quick Google search, so I feel that an example would be too much.
I'm having a little problem with an activity I have loading in a TabGroupActivity
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_profile);
f = new Functions();
String j = f.getUserInfo();
arialFont = Typeface.createFromAsset(this.getAssets(),"Arial.ttf");
username = (TextView)findViewById(R.id.txtProfileName);
firstname = (TextView)findViewById(R.id.txtName);
Address1 = (TextView)findViewById(R.id.txtAdd1);
Cit = (TextView)findViewById(R.id.txtCity);
PostCode = (TextView)findViewById(R.id.txtPost);
Coun = (TextView)findViewById(R.id.txtCountry);
Phon = (TextView)findViewById(R.id.txtPhone);
dob = (TextView)findViewById(R.id.txtDOB);
gender = (TextView)findViewById(R.id.txtGender);
yourDetails = (Button)findViewById(R.id.Button01);
payment = (Button)findViewById(R.id.Button02);
billing = (Button)findViewById(R.id.Button03);
history = (Button)findViewById(R.id.Button04);
yourDetails.setTypeface(arialFont); <-- Null Pointer exception starts here
payment.setTypeface(arialFont);
billing.setTypeface(arialFont);
history.setTypeface(arialFont);
try {
parseData(j);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The error I recieve from the code is this:
02-27 13:22:47.278: E/AndroidRuntime(929): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.Ticketline.Ticketline/com.Ticketline.Ticketline.UserProfile}: java.lang.NullPointerException
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1796)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
02-27 13:22:47.278: E/AndroidRuntime(929): at com.Ticketline.Ticketline.TabGroupActivity.startChildActivity(TabGroupActivity.java:61)
02-27 13:22:47.278: E/AndroidRuntime(929): at com.Ticketline.Ticketline.Account.onCreate(Account.java:33)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Activity.performCreate(Activity.java:4465)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
02-27 13:22:47.278: E/AndroidRuntime(929): ... 18 more
02-27 13:22:47.278: E/AndroidRuntime(929): Caused by: java.lang.NullPointerException
02-27 13:22:47.278: E/AndroidRuntime(929): at com.Ticketline.Ticketline.UserProfile.onCreate(UserProfile.java:83)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Activity.performCreate(Activity.java:4465)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-27 13:22:47.278: E/AndroidRuntime(929): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
02-27 13:22:47.278: E/AndroidRuntime(929): ... 26 more
I know the issue is with setting the buttons typeface to Arial, the problem is I don't understand why this is an issue. If I comment the setTypeface lines out it works fine and will move onto other activity which do have their button typefaces set within the TabGroupActivity which perplexes me even more.
Top marks for anyone that can explain this to me
Figured the issue out, the coder who worked on this app before me gave the history button the id "btnHistory" instead of "Button04". Naturally this resolved in a null pointer error because the id "Button04" doesn't exist in that activity.