I'm trying to add an SQLite database to my android app.
I made a separate class for the pin table (Pin.java) and
a database handler in MySQLiteHelper.java
Now I'm trying to call the addPin method in one of my activities and
it gives me an error:
http://pastebin.com/8h4k3Quh
11-20 18:39:44.011: E/SQLiteLog(22644): (1) no such table: tblPins
11-20 18:39:44.021: E/SQLiteDatabase(22644): Error inserting pinMessage=testinh pinDuration=1 pinTitle=test
11-20 18:39:44.021: E/SQLiteDatabase(22644): android.database.sqlite.SQLiteException: no such table: tblPins (code 1): , while compiling: INSERT INTO tblPins(pinMessage,pinDuration,pinTitle) VALUES (?,?,?)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1467)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1339)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at com.github.viperdream.MySQLiteHelper.addPin(MySQLiteHelper.java:54)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at com.github.viperdream.AddPinActivity.btnCreatePin(AddPinActivity.java:39)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at java.lang.reflect.Method.invoke(Method.java:525)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.view.View$1.onClick(View.java:3628)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.view.View.performClick(View.java:4240)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.view.View$PerformClick.run(View.java:17721)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.os.Handler.handleCallback(Handler.java:730)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.os.Looper.loop(Looper.java:137)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at java.lang.reflect.Method.invoke(Method.java:525)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 18:39:44.021: E/SQLiteDatabase(22644): at dalvik.system.NativeStart.main(Native Method)
11-20 18:39:44.021: E/SQLiteLog(22644): (1) no such table: tblPins
11-20 18:39:44.021: D/AndroidRuntime(22644): Shutting down VM
11-20 18:39:44.021: W/dalvikvm(22644): threadid=1: thread exiting with uncaught exception (group=0x415df700)
11-20 18:39:44.021: E/AndroidRuntime(22644): FATAL EXCEPTION: main
11-20 18:39:44.021: E/AndroidRuntime(22644): java.lang.IllegalStateException: Could not execute method of the activity
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.view.View$1.onClick(View.java:3633)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.view.View.performClick(View.java:4240)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.view.View$PerformClick.run(View.java:17721)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.os.Handler.handleCallback(Handler.java:730)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.os.Looper.loop(Looper.java:137)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.app.ActivityThread.main(ActivityThread.java:5103)
11-20 18:39:44.021: E/AndroidRuntime(22644): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 18:39:44.021: E/AndroidRuntime(22644): at java.lang.reflect.Method.invoke(Method.java:525)
11-20 18:39:44.021: E/AndroidRuntime(22644): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-20 18:39:44.021: E/AndroidRuntime(22644): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-20 18:39:44.021: E/AndroidRuntime(22644): at dalvik.system.NativeStart.main(Native Method)
11-20 18:39:44.021: E/AndroidRuntime(22644): Caused by: java.lang.reflect.InvocationTargetException
11-20 18:39:44.021: E/AndroidRuntime(22644): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 18:39:44.021: E/AndroidRuntime(22644): at java.lang.reflect.Method.invoke(Method.java:525)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.view.View$1.onClick(View.java:3628)
11-20 18:39:44.021: E/AndroidRuntime(22644): ... 11 more
11-20 18:39:44.021: E/AndroidRuntime(22644): Caused by: android.database.sqlite.SQLiteException: no such table: tblPins (code 1): , while compiling: Select * FROM tblPins WHERE pinTitle = "test"
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
11-20 18:39:44.021: E/AndroidRuntime(22644): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
11-20 18:39:44.021: E/AndroidRuntime(22644): at com.github.viperdream.MySQLiteHelper.findPin(MySQLiteHelper.java:61)
11-20 18:39:44.021: E/AndroidRuntime(22644): at com.github.viperdream.AddPinActivity.btnCreatePin(AddPinActivity.java:41)
It says it can't find the table tblPins, but I thought it'd create automatically after calling the function.
I can't seem to figure this one out, here's my code:
Databasehandler, MySQLiteHelper.java:
public class MySQLiteHelper extends SQLiteOpenHelper{
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "PinDB";
private static final String TABLE_PINS = "tblPins";
private static final String KEY_PINID = "pin_id";
private static final String KEY_PINTITLE = "pinTitle";
private static final String KEY_PINMESSAGE = "pinMessage";
private static final String KEY_PINDURATION = "pinDuration";
private static final String[] COLUMNS = {KEY_PINID, KEY_PINTITLE, KEY_PINMESSAGE, KEY_PINDURATION};
public MySQLiteHelper(Context context, String name, CursorFactory factory, int version){
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
#Override
public void onCreate(SQLiteDatabase db){
db.execSQL("CREATE TABLE "
+ TABLE_PINS + " ("
+ KEY_PINID +" INTEGER PRIMARY KEY," + KEY_PINTITLE +
" TEXT,"+
KEY_PINMESSAGE+" TEXT,"
+ KEY_PINDURATION +" INTEGER "+ ")");
}
#Override
public void onUpgrade(SQLiteDatabase db, int oldVersio, int newVersion){
db.execSQL("DROP TABLE IF EXISTS tblPins");
this.onCreate(db);
}
public void addPin(Pin pin){
Log.d("addPin", pin.toString());
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_PINTITLE, pin.getPinTitle());
values.put(KEY_PINMESSAGE, pin.getPinMessage());
values.put(KEY_PINDURATION, pin.getPinDuration());
db.insert(TABLE_PINS, null, values);
db.close();
}
public Pin findPin(String pinTitle){
String query = "Select * FROM " + TABLE_PINS + " WHERE " + KEY_PINTITLE + " = \"" + pinTitle +"\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
Pin pin = new Pin();
if (cursor.moveToFirst()){
cursor.moveToFirst();
pin.setPinID(Integer.parseInt(cursor.getString(0)));
pin.setPinTitle(cursor.getString(1));
pin.setPinMessage(cursor.getString(2));
pin.setPinDuration(Integer.parseInt(cursor.getString(3)));
cursor.close();
}else{
pin = null;
}
db.close();
return pin;
}
public boolean deletePin(String pinTitle){
boolean result = false;
String query = "Select * FROM " + TABLE_PINS + " WHERE " + KEY_PINTITLE + " = \"" + pinTitle + "\"";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(query, null);
Pin pin = new Pin();
if(cursor.moveToFirst()){
pin.setPinID(Integer.parseInt(cursor.getString(0)));
db.delete(TABLE_PINS, KEY_PINID + " = ?",
new String[] { String.valueOf(pin.getID()) });
cursor.close();
result = true;
}
db.close();
return result;
}
}
If you need any more information, please do not hesitate to ask!
Thanks in advance
Update: I've managed to get the table in, I've put onCreate() in the addPin method, but is there any reason why this method doesn't get called when I don't put it in addPin?
Related
Other stuck posts unfortunately couldn't help me.
When I clicked button while easy radiobutton is checked, the app stops working. I couldn't go and see another activity.
Sender Side:
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if(radiobutton_arm_triceps_easy.isChecked()) {
String dene = "my example test";
int myValue=2;
Intent intent = new Intent(getApplicationContext(), exercise_arm_triceps_execute.class);
intent.putExtra("attempt1", myValue );
startActivity(intent);
}
}
});
Receiver Side:
int receiveValue=getIntent().getIntExtra("attempt1",0);
textshow.setText(receiveValue);
LOGCAT
04-26 16:52:06.320 31527-31527/com.example.kerem.tutorial_project E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.kerem.tutorial_project, PID: 31527
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kerem.tutorial_project/com.example.kerem.tutorial_project.exercise_arm_triceps_execute}: android.content.res.Resources$NotFoundException: String resource ID #0x2
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x2
at android.content.res.Resources.getText(Resources.java:244)
at android.support.v7.widget.ResourcesWrapper.getText(ResourcesWrapper.java:52)
at android.widget.TextView.setText(TextView.java:3888)
at com.example.kerem.tutorial_project.exercise_arm_triceps_execute.onCreate(exercise_arm_triceps_execute.java:28)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Use
textshow.setText(String.valueOf(receiveValue));
I am trying to load JSON data into RecyclerView but I keep getting a NullPointerException. Can anyone please tell me what I am doing wrong? I have been trying to get this working for days now but I can't seem to find the issue. Here is my code:
list_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/listItemLayout">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="#+id/yesButton"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="#00FF00" />
<ImageButton
android:id="#+id/noButton"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="#FF0000" />
</LinearLayout>
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/image_1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:scaleType="fitXY"
android:src="#drawable/placeholder" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:orientation="horizontal">
<com.android.volley.toolbox.NetworkImageView
android:id="#+id/thumbnail"
android:layout_width="40dp"
android:layout_height="40dp"
android:scaleType="fitXY"
android:src="#drawable/placeholder" />
<TextView
android:id="#+id/pUsername"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="username" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<ImageButton
android:id="#+id/postMenu"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#000"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
fragment_home.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" />
</LinearLayout>
FragmentHome.java:
public class FragmentHome extends Fragment {
private final String postsUrl = "http://www.example.com/fetch_posts.php";
private ProgressDialog progressDialog;
private static final String TAG = "RecyclerViewExample";
private List<ListItems> listItemsList = new ArrayList<>();
private RecyclerView mRecyclerView;
private MyRecyclerAdapter adapter;
public FragmentHome() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (container == null) {
return null;
}
View view = inflater.inflate(R.layout.fragment_home, container, false);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
mRecyclerView.addItemDecoration(
new HorizontalDividerItemDecoration.Builder(getActivity())
.color(Color.BLACK)
.build());
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(linearLayoutManager);
updateFeed();
return view;
}
public void updateFeed() {
showPD();
adapter = new MyRecyclerAdapter(getActivity(), listItemsList);
mRecyclerView.setAdapter(adapter);
RequestQueue request = Volley.newRequestQueue(getActivity());
adapter.clearAdapter();
JsonArrayRequest req = new JsonArrayRequest(postsUrl, new Response.Listener<JSONArray>() {
#Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
try {
for (int i = 0; i < response.length(); i++) {
JSONObject post = (JSONObject) response.get(i);
ListItems item = new ListItems();
item.setImage_1(post.getString("image_1"));
item.setUsername(post.getString("username"));
listItemsList.add(item);
}
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePD();
Toast.makeText(getActivity(), "Volley Error: " + error.getMessage(), Toast.LENGTH_LONG).show();
}
});
request.add(req);
}
private void showPD() {
if (progressDialog == null) {
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.show();
}
}
private void hidePD() {
if (progressDialog != null) {
progressDialog.dismiss();
progressDialog = null;
}
}
#Override
public void onDestroy() {
super.onDestroy();
hidePD();
}
}
fetch_posts.php:
<?php
$db = mysql_connect("localhost", "username", "password");
if (!$db) {
die('Could not connect to db: '.mysql_error());
}
mysql_select_db("app_db", $db);
$result = mysql_query("SELECT * FROM posts", $db);
$json_response = array();
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$row_array['id'] = $row['id'];
$row_array['username'] = $row['username'];
$row_array['image_1'] = $row['image_1'];
$row_array['occasion'] = $row['occasion'];
$row_array['date/time'] = $row['date/time'];
$row_array['yes'] = $row['yes'];
$row_array['no'] = $row['no'];
array_push($json_response, $row_array);
}
echo json_encode($json_response);
fclose($db);
?>
And this is the logcat error:
11-20 12:54:52.337 2064-2064/? D/dalvikvm: Late-enabling CheckJNI
11-20 12:54:52.357 2064-2070/? E/jdwp: Failed sending reply to debugger: Broken pipe
11-20 12:54:52.357 2064-2070/? D/dalvikvm: Debugger has detached; object registry had 1 entries
11-20 12:54:52.401 2064-2064/? D/dalvikvm: GC_FOR_ALLOC freed 87K, 5% free 3778K/3936K, paused 3ms, total 3ms
11-20 12:54:52.401 2064-2064/? I/dalvikvm-heap: Grow heap (frag case) to 6.169MB for 2536932-byte allocation
11-20 12:54:52.413 2064-2073/? D/dalvikvm: GC_FOR_ALLOC freed <1K, 3% free 6255K/6416K, paused 12ms, total 12ms
11-20 12:54:52.421 2064-2067/? D/dalvikvm: GC_CONCURRENT freed <1K, 3% free 6255K/6416K, paused 0ms+1ms, total 9ms
11-20 12:54:52.521 2064-2067/? D/dalvikvm: GC_CONCURRENT freed 305K, 6% free 6817K/7188K, paused 0ms+2ms, total 18ms
11-20 12:54:52.577 2064-2064/? D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so
11-20 12:54:52.577 2064-2064/? D/: HostConnection::get() New Host Connection established 0xb94e8d78, tid 2064
11-20 12:54:52.601 2064-2064/? D/libEGL: loaded /system/lib/egl/libGLESv1_CM_genymotion.so
11-20 12:54:52.601 2064-2064/? D/libEGL: loaded /system/lib/egl/libGLESv2_genymotion.so
11-20 12:54:52.641 2064-2064/? W/EGL_genymotion: eglSurfaceAttrib not implemented
11-20 12:54:52.645 2064-2064/? E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
11-20 12:54:52.645 2064-2064/? E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384
11-20 12:54:52.653 2064-2064/? E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
11-20 12:54:52.657 2064-2064/? E/OpenGLRenderer: MAX_TEXTURE_SIZE: 16384
11-20 12:54:52.657 2064-2064/? D/OpenGLRenderer: Enabling debug mode 0
11-20 12:54:52.773 2064-2064/? W/EGL_genymotion: eglSurfaceAttrib not implemented
11-20 12:54:53.037 2064-2064/? W/EGL_genymotion: eglSurfaceAttrib not implemented
11-20 12:54:53.141 2064-2064/? D/RecyclerViewExample: [{"yes":"3","occasion":"Birthday Party","id":"1","image_1":"https:\/\/s-media-cache-ak0.pinimg.com\/236x\/e3\/33\/4a\/e3334aa897d8c612dccba223b22ee90d.jpg","username":"alexiz","no":"1","date\/time":"2015-11-19 14:22:00"},{"yes":"3","occasion":"Birthday Party","id":"2","image_1":"https:\/\/i.ytimg.com\/vi\/qJSQ1y7hR2g\/maxresdefault.jpg","username":"alexiz","no":"10","date\/time":"2015-11-19 09:14:06"},{"yes":"3","occasion":"Club","id":"3","image_1":"https:\/\/i.ytimg.com\/vi\/qJSQ1y7hR2g\/maxresdefault.jpg","username":"gell","no":"1","date\/time":"2015-11-04 09:14:06"},{"yes":"8","occasion":"Baby Shower","id":"4","image_1":"https:\/\/i.ytimg.com\/vi\/qJSQ1y7hR2g\/maxresdefault.jpg","username":"jkfldj","no":"1","date\/time":"2015-11-11 09:14:06"}]
11-20 12:54:53.161 2064-2064/? D/dalvikvm: GC_FOR_ALLOC freed 326K, 6% free 7097K/7488K, paused 4ms, total 4ms
11-20 12:54:53.165 2064-2064/? I/dalvikvm-heap: Grow heap (frag case) to 15.575MB for 9000012-byte allocation
11-20 12:54:53.169 2064-2073/? D/dalvikvm: GC_FOR_ALLOC freed <1K, 3% free 15886K/16280K, paused 3ms, total 3ms
11-20 12:54:53.173 2064-2067/? D/dalvikvm: GC_CONCURRENT freed 5K, 3% free 15880K/16280K, paused 0ms+0ms, total 4ms
11-20 12:54:53.225 2064-2064/? D/AndroidRuntime: Shutting down VM
11-20 12:54:53.225 2064-2064/? W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d43b20)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: FATAL EXCEPTION: main
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: Process: com.example.app, PID: 2064
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: java.lang.NullPointerException
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at com.android.volley.toolbox.NetworkImageView.loadImageIfNecessary(NetworkImageView.java:160)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at com.android.volley.toolbox.NetworkImageView.onLayout(NetworkImageView.java:209)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView$LayoutManager.layoutDecorated(RecyclerView.java:7036)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1429)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1334)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:563)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2847)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3145)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1627)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.View.layout(View.java:14817)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1740)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:574)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:544)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:733)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:136)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5001)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:515)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-20 12:54:53.225 2064-2064/? E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
EDIT --------------------------------------------------
MyRecyclerAdapter.java:
public class MyRecyclerAdapter extends RecyclerView.Adapter<ListRowViewHolder> {
private List<ListItems> listItemsList;
private Context mContext;
private ImageLoader mImageLoader;
private int focusedItem = 0;
public MyRecyclerAdapter(Context context, List<ListItems> listItemsList) {
this.mContext = context;
this.listItemsList = listItemsList;
}
#Override
public ListRowViewHolder onCreateViewHolder(final ViewGroup viewGroup, int position) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.list_item, null);
ListRowViewHolder holder = new ListRowViewHolder(v);
holder.recLayout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.d("List Size", Integer.toString(getItemCount()));
}
});
return holder;
}
#Override
public void onBindViewHolder(final ListRowViewHolder listRowViewHolder, int position) {
ListItems listItems = listItemsList.get(position);
listRowViewHolder.itemView.setSelected(focusedItem == position);
listRowViewHolder.getLayoutPosition();
listRowViewHolder.thumbnail.setImageUrl(listItems.getProfilePicture(), mImageLoader);
listRowViewHolder.thumbnail.setDefaultImageResId(R.drawable.placeholder);
listRowViewHolder.image_1.setImageUrl(listItems.getImage_1(), mImageLoader);
listRowViewHolder.image_1.setDefaultImageResId(R.drawable.placeholder);
listRowViewHolder.username.setText(Html.fromHtml(listItems.getUsername()));
}
public void clearAdapter() {
listItemsList.clear();
notifyDataSetChanged();
}
#Override
public int getItemCount() {
return (null != listItemsList ? listItemsList.size() : 0);
}
}
I found where my issue was. I declared my mImageLoader variable in my MyRecyclerAdapter class but I never assigned it. Once I did that, it seems to be working. Images still look funny but I can work with that. Here is the line that I needed to add before listRowViewHolder.thumbnail.setImageUrl(listItems.getProfilePicture(), mImageLoader); line in onBindViewHolder.
Line added:
mImageLoader = MySingleton.getInstance(mContext).getImageLoader();
Thank you sourabhbands, I couldn't have found the error without you.
This is my update query,
ContentValues value = new ContentValues();
value.put(DBhelper.Amount, txtBudget.getText().toString());
db = helper.getWritableDatabase();
db.update(DBhelper.TABLE1, value," "+DBhelper.Description+"='"+value_in_tv,null);
db.close();
fetchData2();
Toast.makeText(this, "Update Successfully", Toast.LENGTH_LONG).show();
clearfield();
when click the button to update,it's giving fatal exception error.
value_in_tv this is the value I got from another class
Bundle data_from_list= getIntent().getExtras();
value_in_tv= data_from_list.getString("passed data key");
txr.setText(value_in_tv);
Error:
10-18 20:45:57.812 18632-18632/com.example.username.weddingplanning
E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.database.sqlite.SQLiteException: unrecognized token: "'suba" (code 1): , while compiling: UPDATE Category SET amount=?
WHERE description='suba
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native
Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1113)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:686)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1669)
at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1620)
at com.example.username.weddingplanning.addbudget.checkIfRowPresent(addbudget.java:134)
at com.example.username.weddingplanning.addbudget.onClick(addbudget.java:114)
at android.view.View.performClick(View.java:4439)
at android.view.View$PerformClick.run(View.java:18398)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
You forgot the closing ' in the where clause:
db.update(DBhelper.TABLE1, value," "+DBhelper.Description+"='"+value_in_tv + "'",null)
I have called a function returnCurrentNameById() by passing the id of the particular row. But it gives an error.
String[] s1;
public String[] returnCurrentNameById(int k) throws SQLException{
String[] columns = new String[]{ KEY_ID1, KEY_NAME, Key_DOB, KEY_AGE, KEY_PHONE_NO, Key_EXPERIENCE, KEY_EMAIL, KEY_STATUS, KEY_STATUS};
SQLiteDatabase db3 = this.getReadableDatabase();
Cursor c = db3.query(DATA_BASE_TABLE_NAME1, columns, KEY_ID1 + "=" + k, null, null, null, null);
if (c != null){
c.moveToFirst();
for(int i = 0; i<=8; i++){
s1[i] = c.getString(i);
}
return s1;
}
return null;
}
The Log cat error report is:
02-15 16:38:13.424 1545-1545/world.com.my`enter code here`progect09 D/AndroidRuntime﹕ Shutting down VM
02-15 16:38:13.464 1545-1545/world.com.myprogect09 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x2bc9a300)
02-15 16:38:13.533 1545-1545/world.com.myprogect09 E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:3591)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3586)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at world.com.myprogect09.DataBaseSQL.returnCurrentNameById1(DataBaseSQL.java:209)
at world.com.myprogect09.ThirdActivity.isClicked(ThirdActivity.java:74)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at android.view.View$1.onClick(View.java:3586)
at android.view.View.performClick(View.java:4084)
at android.view.View$PerformClick.run(View.java:16966)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
02-15 16:38:34.491 1545-1545/world.com.myprogect09 I/Process﹕ Sending signal. PID: 1545 SIG: 9
You have not initialized your s1 array.
Use
s1 = new String[9];
to allocate an array of 9 elements.
Also check the return value of moveToFirst() so you don't get an exception in case the query returns no rows.
Replace
Cursor c = db3.query(DATA_BASE_TABLE_NAME1, columns, KEY_ID1 + "=" + k, null, null, null, null);
with
Cursor c = db3.query(DATA_BASE_TABLE_NAME1, columns, KEY_ID1 + " = ?", new String[]{String.valueOf(k)}, null, null, null);
Why am I getting a NullPointerException when I am pointing to something that is there?
View header = (View)inflater.inflate(R.layout.listview_header_row, null);
Class Code
public class FeaturedDealsFragment extends Fragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.fragment_featured_deals, container, false);
ListView LV = (ListView) this.getActivity().findViewById(R.id.dealsListView);
Deal deal_data[] = new Deal[]
{
new Deal("Deal 1", R.drawable.scenery, "500/100 Supporters", "$500"),
new Deal("Deal 2", R.drawable.scenery, "500/100 Supporters", "$500"),
new Deal("Deal 3", R.drawable.scenery, "500/100 Supporters", "$500"),
new Deal("Deal 4", R.drawable.scenery, "500/100 Supporters", "$500"),
new Deal("Deal 5", R.drawable.scenery, "500/100 Supporters", "$500")
};
DealAdapter adapter = new DealAdapter(getActivity(), R.layout.listview_item_row, deal_data);
View header = (View)inflater.inflate(R.layout.listview_header_row, null);
LV.addHeaderView(header);
LV.setAdapter(adapter);
return V;
}
}
listview_header_row XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="#+id/txtHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#ffffff"
style="#style/fragment_main_heading"
android:textColor="#000000"
android:text="#string/featuredDeals" />
</LinearLayout>
Logcat
11-20 16:53:10.868: E/AndroidRuntime(29998): FATAL EXCEPTION: main
11-20 16:53:10.868: E/AndroidRuntime(29998): java.lang.NullPointerException
11-20 16:53:10.868: E/AndroidRuntime(29998): at com.karkinos.croupon.FeaturedDealsFragment.onCreateView(FeaturedDealsFragment.java:31)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.View.measure(View.java:15395)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4826)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.View.measure(View.java:15395)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.widget.LinearLayout.measureVertical(LinearLayout.java:833)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.View.measure(View.java:15395)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4826)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-20 16:53:10.868: E/AndroidRuntime(29998): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2362)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.View.measure(View.java:15395)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1985)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1226)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1399)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4553)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.Choreographer.doFrame(Choreographer.java:525)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.os.Handler.handleCallback(Handler.java:615)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.os.Handler.dispatchMessage(Handler.java:92)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.os.Looper.loop(Looper.java:137)
11-20 16:53:10.868: E/AndroidRuntime(29998): at android.app.ActivityThread.main(ActivityThread.java:4950)
11-20 16:53:10.868: E/AndroidRuntime(29998): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 16:53:10.868: E/AndroidRuntime(29998): at java.lang.reflect.Method.invoke(Method.java:511)
11-20 16:53:10.868: E/AndroidRuntime(29998): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
11-20 16:53:10.868: E/AndroidRuntime(29998): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
11-20 16:53:10.868: E/AndroidRuntime(29998): at dalvik.system.NativeStart.main(Native Method)
Try this..
ListView LV = (ListView) V.findViewById(R.id.dealsListView);
instead of this..
ListView LV = (ListView) this.getActivity().findViewById(R.id.dealsListView);
because V is the parent view so you need to use this..