I rewrote my app to a new project to have the code tidier and also use pre-defined fullscreen activity from Android Studio. The app was working perfectly fine (at least past the point when it crashes now). The app populates a gridview from an SQLite database via custom CursorAdaper, and the error seems to be there, more specifically - it looks like a problem with the layout that should be populated (A linear view of fixed dimensions, 2 children - ImageView and TextView.
Ichecked the resource from the first line in R.java and this value is assigned to the name of the layout that should be inflated by the cursor. Any idea how to fix it?
W/ResourceType: Failure getting entry for 0x7f040031 (t=3 e=49) (error -75)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.madry.mtg, PID: 21183
android.content.res.Resources$NotFoundException: Resource ID #0x7f040031
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:198)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:2114)
at android.content.res.Resources.getLayout(Resources.java:1115)
at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
at com.madry.mtg.MyCursorAdapter.newView(MyCursorAdapter.java:33)
at android.widget.CursorAdapter.getView(CursorAdapter.java:285)
at android.widget.AbsListView.obtainView(AbsListView.java:2433)
at android.widget.GridView.onMeasure(GridView.java:1065)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1117)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:642)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:393)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19785)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:690)
at android.view.View.measure(View.java:19785)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1362)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1611)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1250)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6311)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:619)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6217)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
The MyCursorAdapter class
import android.content.Context;
import android.database.Cursor;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import static com.madry.mtg.MyDBHandler.COLUMN_COLOUR;
import static com.madry.mtg.MyDBHandler.COLUMN_POWER;
import static com.madry.mtg.MyDBHandler.COLUMN_TAP;
import static com.madry.mtg.MyDBHandler.COLUMN_TS;
public class MyCursorAdapter extends CursorAdapter{
private LayoutInflater cursorInflater;
public MyCursorAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
cursorInflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return cursorInflater.inflate(R.layout.token, parent, false);
}
#Override
public void bindView(View view, Context context, Cursor cursor) {
Log.d("adapter", "zaczelo wiazac");
Symbol symbol = new Symbol();
String sciezka = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_COLOUR));
symbol.setPath(sciezka);
int path = symbol.getPath();
ImageView clr = (ImageView) view.findViewById(R.id.imageView);
clr.setImageResource(path);
int tap = cursor.getInt((cursor.getColumnIndexOrThrow(COLUMN_TAP)));
if (tap == 0){
view.setRotation(0);
} else {
view.setRotation(20);
}
TextView stats = (TextView) view.findViewById(R.id.textView2);
String p = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_POWER))+
"/" + cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_TS));
stats.setText(p);
}
}
Related
Heyhey :)
I looked at several Questions to the same topic, but I found no solution to my problem.
and my button of add to bag it does not work
anyone here know how to help me
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.database.sqlite.SQLiteDatabase.getVersion()' on a null object reference
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getWritableDatabase(SQLiteAssetHelper.java:178)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getReadableDatabase(SQLiteAssetHelper.java:254)
at com.yanistk.tkfood.Database.Database.getCarts(Database.java:26)
at com.yanistk.tkfood.Cart.loadListFood(Cart.java:102)
at com.yanistk.tkfood.Cart.onCreate(Cart.java:63)
The Logcat:
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.database.sqlite.SQLiteDatabase.getVersion()' on a null object reference
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getWritableDatabase(SQLiteAssetHelper.java:178)
at com.readystatesoftware.sqliteasset.SQLiteAssetHelper.getReadableDatabase(SQLiteAssetHelper.java:254)
at com.yanistk.tkfood.Database.Database.getCarts(Database.java:26)
at com.yanistk.tkfood.Cart.loadListFood(Cart.java:102)
at com.yanistk.tkfood.Cart.onCreate(Cart.java:63)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
2020-06-15 17:16:35.213 1759-1908/system_process E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
2020-06-15 17:16:35.213 1759-1908/system_process E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
2020-06-15 17:16:35.587 2379-14186/com.google.android.gms.persistent E/SQLiteDatabase: Error inserting service_kind=0 source=16 tag=Measurement.PackageMeasurementTaskService.UPLOAD_TASK_TAG target_package=com.google.android.gms requires_charging=0 source_version=200414000 required_network_type=0 flex_time=506000 target_class=com.google.android.gms.measurement.PackageMeasurementTaskService runtime=1592237795535 retry_strategy={"maximum_backoff_seconds":{"3600":0},"initial_backoff_seconds":{"30":0},"retry_policy":{"0":0}} required_idleness_state=0 period=1014000 last_runtime=0 task_type=0 job_id=-1 user_id=0
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: pending_ops.tag, pending_ops.target_class, pending_ops.target_package, pending_ops.user_id (code 2067)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1474)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1343)
at aozt.a(:com.google.android.gms#200414022#20.04.14 (040700-294335909):147)
at aozi.a(:com.google.android.gms#200414022#20.04.14 (040700-294335909):182)
at aozi.a(:com.google.android.gms#200414022#20.04.14 (040700-294335909):25)
at aozi.a(:com.google.android.gms#200414022#20.04.14 (040700-294335909):177)
at aovr.run(:com.google.android.gms#200414022#20.04.14 (040700-294335909):8)
at srw.b(:com.google.android.gms#200414022#20.04.14 (040700-294335909):14)
at srw.run(:com.google.android.gms#200414022#20.04.14 (040700-294335909):2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at sxw.run(:com.google.android.gms#200414022#20.04.14 (040700-294335909):0)
at java.lang.Thread.run(Thread.java:761)
2020-06-15 17:21:35.235 1759-2314/system_process E/ActivityManager: Found activity ActivityRecord{73a2e8e u0 com.yanistk.tkfood/.MainActivity t74 f} in proc activity list using null instead of expected ProcessRecord{d5573e 16555:com.yanistk.tkfood/u0a80}
database
package com.yanistk.tkfood.Database;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import com.google.firestore.v1.StructuredQuery;
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
import com.yanistk.tkfood.model.Order;
import java.util.ArrayList;
import java.util.List;
public class Database extends SQLiteAssetHelper {
private static final String DB_NAME="jsonDB.db";
private static final int DB_VER=1;
public Context context;
public Database(Context context) {
super(context, DB_NAME, null, DB_VER);
this.context=context;
}
public List<Order> getCarts(){
SQLiteDatabase db=this.getReadableDatabase();
SQLiteQueryBuilder qb=new SQLiteQueryBuilder();
String[]sqlSelect={"ProductName","ProductId","Quantity","Price","Discount"};
String sqlTable="OrderDetail";
qb.setTables(sqlTable);
Cursor c=qb.query(db,sqlSelect,null,null,null,null,null);
final List<Order>result=new ArrayList<>();
if (c.moveToFirst()){
do {
result.add(new Order(c.getString(c.getColumnIndex("ProductId")),
c.getString(c.getColumnIndex("ProductName")),
c.getString(c.getColumnIndex("Price")),
c.getString(c.getColumnIndex("Quantity")),
c.getString(c.getColumnIndex("Discount"))
));
}while (c.moveToNext());
}
return result;
}
public void addToCart(Order order){
SQLiteDatabase db=this.getReadableDatabase();
String query=String.format("INSERT OR REPLACE INTO OrderDetail(ProductId,ProductName,Quantity,Price,Discount) VALUES('%s','%s','%s','%s','%s');",
order.getProductId(),
order.getProductName(),
order.getPrice(),
order.getQuantity(),
order.getDiscount());
db.execSQL(query);
}
public void cleanCart(){
SQLiteDatabase db=this.getReadableDatabase();
String query=String.format("DELETE FROM OrderDetail");
db.execSQL(query);
}
}
cart.java
package com.yanistk.tkfood;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.yanistk.tkfood.Common.Common;
import com.yanistk.tkfood.Database.Database;
import com.yanistk.tkfood.model.Order;
import com.yanistk.tkfood.model.Request;
import com.yanistk.tkfood.viewHolder.CartAdapter;
import java.util.ArrayList;
import java.util.List;
public class Cart extends AppCompatActivity {
RecyclerView recyclerView;
RecyclerView.LayoutManager layoutManager;
FirebaseDatabase database;
DatabaseReference requests;
TextView txtTotalPrice;
Button btnPlace;
List<Order> cart=new ArrayList<>();
CartAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cart);
database=FirebaseDatabase.getInstance();
requests=database.getReference("Requests");
//Init
recyclerView=(RecyclerView)findViewById(R.id.listCart);
recyclerView.setHasFixedSize(true);
layoutManager=new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
txtTotalPrice=(TextView)findViewById(R.id.total);
btnPlace=(Button)findViewById(R.id.btnPlace);
btnPlace.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
showAlertDialog();
}
});
loadListFood();
}
private void showAlertDialog() {
AlertDialog.Builder alertDialog=new AlertDialog.Builder(Cart.this);
alertDialog.setTitle("Un pas de plus");
alertDialog.setMessage("Entrer votre address(Le lieu de livraion): ");
final EditText edtAddress=new EditText(Cart.this);
LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
);
edtAddress.setLayoutParams(lp);
alertDialog.setView(edtAddress);
alertDialog.setPositiveButton("Envoyer", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
Request request=new Request(
Common.currentUser.getName(),
Common.currentUser.getPhone(),
edtAddress.getText().toString(),
txtTotalPrice.getText().toString(),
cart
);
//submit to firebase
requests.child(String.valueOf(System.currentTimeMillis()))
.setValue(request);
//delete cart
new Database(getBaseContext()).cleanCart();
Toast.makeText(Cart.this, "Merci de passer la commande", Toast.LENGTH_SHORT).show();
finish();
}
});
alertDialog.show();
}
private void loadListFood() {
cart=new Database(this).getCarts();
adapter=new CartAdapter(cart,this);
recyclerView.setAdapter(adapter);
//calculate total
int total=0;
for (Order order:cart){
total+=(Integer.parseInt(order.getPrice()))*(Integer.parseInt(order.getQuantity()));
txtTotalPrice.setText(total);
}
}
}
My app keeps crashing since I started using a TextWatcher...
As you can see below i made a TextWatcher to 3 EditText fields...
And i made a button which listens to the 3 EditText..
If they are empty the button become disabled.
When the fields are filled the button should become enabled..
package com.example.magazijnapp;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.MenuPopupWindow;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
import java.sql.Array;
public class MainActivity extends AppCompatActivity {
Spinner spinnermagazijn;
Button knop;
private EditText EditTextregisternummerbalk;
private EditText EditTextticketnummerbalk;
private EditText EditTextartikelnummerbalk;
private Button knopconfirm;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditTextregisternummerbalk = findViewById(R.id.registernummerbalk);
EditTextticketnummerbalk = findViewById(R.id.ticketnummerbalk);
EditTextartikelnummerbalk = findViewById(R.id.artikelnummerbalk);
knopconfirm = findViewById(R.id.knop);
EditTextregisternummerbalk.addTextChangedListener(invulTextWatcher);
EditTextticketnummerbalk.addTextChangedListener(invulTextWatcher);
EditTextartikelnummerbalk.addTextChangedListener(invulTextWatcher);
}
private TextWatcher invulTextWatcher = new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String registernummerinput = EditTextregisternummerbalk.getText().toString().trim();
String ticketnummerinput = EditTextticketnummerbalk.getText().toString().trim();
String artikelnummerinput = EditTextartikelnummerbalk.getText().toString().trim();
knopconfirm.setEnabled(!registernummerinput.isEmpty() && !ticketnummerinput.isEmpty() &&! artikelnummerinput.isEmpty());
}
#Override
public void afterTextChanged(Editable s) {
}
};
{
spinnermagazijn = findViewById(R.id.spinnermagazijn);
knop = findViewById(R.id.knop);
populatespinnermagazijn();
// Dit is het stukje voor de Knop afboeken waarmee je een melding genereerd, String aanpassen voor ander resultaat.
knop.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, (R.string.succes), Toast.LENGTH_SHORT) .show();
}
});
}
// Dit gedeelte is voor de spinner.
private void populatespinnermagazijn() {
ArrayAdapter<String> magazijnenAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.steunpunten));
magazijnenAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnermagazijn.setAdapter(magazijnenAdapter);
}
}
And this is my logcat...
03-19 21:04:06.293 21151-21151/? E/libprocessgroup: failed to make and chown /acct/uid_10060: Read-only file system
03-19 21:04:06.293 21151-21151/? W/Zygote: createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
03-19 21:04:06.293 21151-21151/? I/art: Not late-enabling -Xcheck:jni (already on)
03-19 21:04:06.313 21151-21161/? I/art: Debugger is no longer active
03-19 21:04:06.351 21151-21151/? D/AndroidRuntime: Shutting down VM
03-19 21:04:06.354 21151-21151/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.magazijnapp, PID: 21151
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.magazijnapp/com.example.magazijnapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference
at android.content.ContextWrapper.getApplicationInfo(ContextWrapper.java:149)
at android.view.ContextThemeWrapper.getTheme(ContextThemeWrapper.java:99)
at android.content.Context.obtainStyledAttributes(Context.java:437)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:692)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
at androidx.appcompat.app.AppCompatDelegateImpl.findViewById(AppCompatDelegateImpl.java:479)
at androidx.appcompat.app.AppCompatActivity.findViewById(AppCompatActivity.java:214)
at com.example.magazijnapp.MainActivity.<init>(MainActivity.java:73)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.Class.newInstance(Class.java:1606)
at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
03-19 21:04:07.996 21151-21151/? I/Process: Sending signal. PID: 21151 SIG: 9
There are two findViewById(R.id.knop);
remove this line:
knop = findViewById(R.id.knop);
and change :
knopconfirm.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, (R.string.succes), Toast.LENGTH_SHORT) .show();
}
});
You are saying your app is crashing since you started using TextWatcher. So why don't you stop using it?
you can achieve the same thing without using TextWatcher by doing this.
knop.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String registernummerinput = EditTextregisternummerbalk.getText().toString().trim();
String ticketnummerinput = EditTextticketnummerbalk.getText().toString().trim();
String artikelnummerinput = EditTextartikelnummerbalk.getText().toString().trim();
if((!registernummerinput.isEmpty() && !ticketnummerinput.isEmpty() &&! artikelnummerinput.isEmpty())) {
Toast.makeText(MainActivity.this, (R.string.succes), Toast.LENGTH_SHORT) .show();
}
}
});
you will not need any TextWathcer just modify the listner
I am trying to permanently save some of the visited places by the user. So, when ever i run my project in android studio i get the error
"Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.util.ArrayList"
Here is my code:
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.google.android.gms.maps.model.LatLng;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
static ArrayList<String> places= new ArrayList<>();
static ArrayList<LatLng> locations = new ArrayList<>();
static ArrayAdapter arrayAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView listView = (ListView) findViewById(R.id.listView);
SharedPreferences sharedPreferences = this.getSharedPreferences("com.example.lucifer.memorableplaces", Context.MODE_PRIVATE);
ArrayList<String> latitudes = new ArrayList<>();
ArrayList<String> longitudes = new ArrayList<>();
places.clear();
latitudes.clear();
longitudes.clear();
locations.clear();
try {
places = (ArrayList<String>)ObjectSerializer.deserialize(sharedPreferences.getString("places", ObjectSerializer.serialize(new ArrayList<String>())));
latitudes = (ArrayList<String>) ObjectSerializer.deserialize(sharedPreferences.getString("latitudes", ObjectSerializer.serialize(new ArrayList<String>())));
longitudes = (ArrayList<String>) ObjectSerializer.deserialize(sharedPreferences.getString("longitudes", ObjectSerializer.serialize(new ArrayList<String>())));
} catch (IOException e) {
e.printStackTrace();
}
if (places.size() > 0 && latitudes.size() > 0 && longitudes.size() > 0) {
if (places.size() == latitudes.size() && latitudes.size() == longitudes.size()) {
for (int i = 0; i < latitudes.size(); i++) {
locations.add(new LatLng(Double.parseDouble(latitudes.get(i)), Double.parseDouble(longitudes.get(i))));
}
}
} else {
places.add("Add a new place...");
locations.add(new LatLng(0, 0));
}
arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, places);
listView.setAdapter(arrayAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(getApplicationContext(), MapsActivity.class);
intent.putExtra("placeNumber", i);
startActivity(intent);
}
});
}
}
and i get the following error:
Process: com.example.lucifer.memorableplaces, PID: 15910
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.lucifer.memorableplaces/com.example.lucifer.memorableplaces.MainActivity}: java.lang.ClassCastException: java.lang.Class cannot be cast to java.util.ArrayList
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5433)
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:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.util.ArrayList
at com.example.lucifer.memorableplaces.MainActivity.onCreate(MainActivity.java:46)
at android.app.Activity.performCreate(Activity.java:5301)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5433)
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:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
The error is at
places = (ArrayList)ObjectSerializer.deserialize(sharedPreferences.getString("places", ObjectSerializer.serialize(new ArrayList())));
I finally got the answer, the error was caused because i was casting a class to arrayList. so i just changed my class to arrayList first then i casted it back to arrayList which solved my problem.
This way. Here i coded MainActivity.class
sharedPreferences.edit().putString("places",ObjectSerializer.serialize(MainActivity.class)).apply();
Whereas it has to be MainActivity.places in following Way
sharedPreferences.edit().putString("places",ObjectSerializer.serialize(MainActivity.places)).apply();
So, here i was actually casting a class to arrayList which gave me this error. Hope any beginner will prevent this mistake from this Question.
Thanks You All...
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am busy building a basic chat app in Android using a tutorial I found online. I copied the code that they use in the example and have had no problems up to this point. Now I am getting the following error:
C:\Users\Brian\AndroidStudioProjects\ChatApp\app\src\main\java\com\example\brian\chatapp\ChatAdapter.java
Error:(20, 14) error: <identifier> expected
Error:(20, 17) error: <identifier> expected
Error:(20, 29) error: <identifier> expected
Error:(20, 32) error: <identifier> expected
Error:(20, 49) error: <identifier> expected
Error:(22, 52) error: <identifier> expected
Error:(22, 53) error: ';' expected
Error:(22, 67) error: <identifier> expected
Error:(22, 70) error: <identifier> expected
Error:(22, 76) error: <identifier> expected
C:\Users\Brian\AndroidStudioProjects\ChatApp\app\src\main\java\com\example\brian\fragments\Chats.java
Error:(26, 28) error: <identifier> expected
Error:(26, 31) error: <identifier> expected
Error:(26, 43) error: <identifier> expected
Error:(26, 46) error: <identifier> expected
Error:(26, 56) error: <identifier> expected
Error:(47, 33) error: '(' or '[' expected
Error:(47, 48) error: not a statement
Error:(47, 54) error: lambda expressions are not supported in -source 1.7
(use -source 8 or higher to enable lambda expressions)
:app:compileDebugJavaWithJavac FAILED
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 1.069 secs
Information:19 errors
Information:0 warnings
Information:See complete output in console
I'm fairly new to Arrays and was hoping to understand them with the help of this tutorial actually, all the other classes have compiled perfectly though. Here is the code:
package com.example.brian.chatapp;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
public class ChatAdapter extends BaseAdapter {
private static LayoutInflater inflater = null;
ArrayList<
ChatMessage>
chatMessageList;
public ChatAdapter(Activity activity, ArrayList<ChatMessage> list) {
chatMessageList = list;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
#Override
public int getCount() {
return chatMessageList.size();
}
#Override
public Object getItem(int position) {
return position;
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ChatMessage message = (ChatMessage) chatMessageList.get(position);
View vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.chatbubble, null);
TextView msg = (TextView) vi.findViewById(R.id.message_text);
msg.setText(message.body);
LinearLayout layout = (LinearLayout) vi
.findViewById(R.id.bubble_layout);
LinearLayout parent_layout = (LinearLayout) vi
.findViewById(R.id.bubble_layout_parent);
// if message is mine then align to right
if (message.isMine) {
layout.setBackgroundResource(R.drawable.bubble2);
parent_layout.setGravity(Gravity.RIGHT);
}
// If not mine then align to left
else {
layout.setBackgroundResource(R.drawable.bubble1);
parent_layout.setGravity(Gravity.LEFT);
}
msg.setTextColor(Color.BLACK);
return vi;
}
public void add(ChatMessage object) {
chatMessageList.add(object);
}
}
Any help would be greatly appreciated! Here is the link to the tutorial that I am using: http://www.tutorialsface.com/2015/08/building-your-own-android-chat-messenger-app-similar-to-whatsapp-using-xmpp-smack-4-1-api-from-scratch-part-1/
:EDIT:
Its seems to have been solved by using #krzyk's method. But now I have run into another problem in the Chats.java class, here is the code:
package com.example.brian.fragments;
import java.util.ArrayList;
import java.util.Random;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import com.example.brian.chatapp.ChatAdapter;
import com.example.brian.chatapp.ChatMessage;
import com.example.brian.chatapp.CommonMethods;
import com.example.brian.chatapp.R;
public class Chats extends Fragment implements OnClickListener {
private EditText msg_edittext;
private String user1 = "khushi", user2 = "khushi1";
private Random random;
public static ArrayList<ChatMessage> chatlist;
public static ChatAdapter chatAdapter;
ListView msgListView;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.chat_layout, container, false);
random = new Random();
((ActionBarActivity) getActivity()).getSupportActionBar().setTitle(
"Chats");
msg_edittext = (EditText) view.findViewById(R.id.messageEditText);
msgListView = (ListView) view.findViewById(R.id.msgListView);
ImageButton sendButton = (ImageButton) view
.findViewById(R.id.sendMessageButton);
sendButton.setOnClickListener(this);
// ----Set autoscroll of listview when a new message arrives----//
msgListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
msgListView.setStackFromBottom(true);
chatlist = new ArrayList<ChatMessage>();
chatAdapter = new ChatAdapter(getActivity(), chatlist);
msgListView.setAdapter(chatAdapter);
return view;
}
#Override
public void onSaveInstanceState(Bundle outState) {
}
public void sendTextMessage(View v) {
String message = msg_edittext.getEditableText().toString();
if (!message.equalsIgnoreCase("")) {
final ChatMessage chatMessage = new ChatMessage(user1, user2,
message, "" + random.nextInt(1000), true);
chatMessage.setMsgID();
chatMessage.body = message;
chatMessage.Date = CommonMethods.getCurrentDate();
chatMessage.Time = CommonMethods.getCurrentTime();
msg_edittext.setText("");
chatAdapter.add(chatMessage);
chatAdapter.notifyDataSetChanged();
}
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.sendMessageButton:
sendTextMessage(v);
}
}
}
And here is the error I am now getting:
07-21 04:20:44.658 1987-1987/com.example.brian.chatapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.brian.chatapp, PID: 1987
java.lang.ClassCastException: com.example.brian.chatapp.MainActivity cannot be cast to android.support.v7.app.ActionBarActivity
at com.example.brian.fragments.Chats.onCreateView(Chats.java:35)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1632)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1235)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1083)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1609)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:669)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:89)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1319)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:734)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
at android.view.View.measure(View.java:17430)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5463)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2560)
at android.view.View.measure(View.java:17430)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2001)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1166)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1372)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller
07-21 04:21:29.569 1987-1987/com.example.brian.chatapp I/Process: Sending signal. PID: 1987 SIG: 9
Change:
ArrayList<
ChatMessage>
chatMessageList;
public ChatAdapter(Activity activity, ArrayList<ChatMessage> list) {
to:
ArrayList<ChatMessage> chatMessageList;
public ChatAdapter(Activity activity, ArrayList<ChatMessage> list) {
Your tutorial is badly written if it shows html entities like < or >. If you encounter them just change < to < and > to >.
You need to remove the < and >:
ArrayList<ChatMessage> chatMessageList;
public ChatAdapter(Activity activity, ArrayList<ChatMessage> list) {
chatMessageList = list;
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
I wanna add toolbar to my android app, however I got "FATAL EXCEPTION: main
java.lang.OutOfMemoryError" when I changed Activity to AppCompatActivity. Here is my code, I don't know why changing a line makes an out of memory error.
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
public class Notifications extends AppCompatActivity {
//public class Notifications extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notifications);
//Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
//setSupportActionBar(myToolbar);
//String[] notificationsDates = {"12Jan 2016", "14Feb 2016", "22Feb 2016", "18Dec 2015", "2Nov 2015", "20Oct 2015", "15Oct 2015"};
//String[] estimationTimes = {"9:00 am", "10:00 am", "11:00 am", "9:00 am", "10:00 am", "10:00 am", "11:00 am"};
final SingleNotification[] notifications = {
new SingleNotification("12Jan2016","9:00 am",R.drawable.fedex,false),
new SingleNotification("14Feb2016","10:00 am",R.drawable.ups,false),
new SingleNotification("22Feb2016","11:00 am",R.drawable.purolator,true),
new SingleNotification("18Dec2015","9:00 am",R.drawable.dhl,true),
new SingleNotification("2Nov2015","10:00 am",R.drawable.fedex,true),
new SingleNotification("20Oct2015","10:00 am",R.drawable.ups,true),
new SingleNotification("15Oct2015","11:00 am",R.drawable.ups,true)
};
ListAdapter listAdapter = new CustomeAdapter(this, notifications);
ListView notificationListView = (ListView) findViewById(R.id.notificationsList);
notificationListView.setAdapter(listAdapter);
notificationListView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String date = String.valueOf(notifications[position].getDeliveryDate());
Toast.makeText(Notifications.this, date, Toast.LENGTH_LONG).show();
}
}
);
}
//String[] notificationsDate = {"Delivery Data: 17Feb2015"};
//String[] notificationsTime = {" Estimated Time: "};
}
here is CustomAdapter:
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.content.res.Resources;
import android.app.Activity;
public class CustomeAdapter extends ArrayAdapter<SingleNotification> {
CustomeAdapter(Context context, SingleNotification[] notifications) {
super(context, R.layout.custome_row, notifications);
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater = LayoutInflater.from(getContext());
View customView = layoutInflater.inflate(R.layout.custome_row, parent, false);
SingleNotification notification = getItem(position);
LinearLayout singleNotificationLayout = (LinearLayout) customView.findViewById(R.id.singleNotificationLayout);
TextView deliveryDateText = (TextView) customView.findViewById(R.id.delivaryDataText);
TextView notificationNumberText = (TextView) customView.findViewById(R.id.notificationNumberText);
TextView estimationTimeText = (TextView) customView.findViewById(R.id.estimationTimeText);
ImageView logoImage = (ImageView) customView.findViewById(R.id.logoImage);
deliveryDateText.setText(notification.getDeliveryDate());
notificationNumberText.setText(String.valueOf(position + 1));
estimationTimeText.setText(notification.getEstimationTime());
logoImage.setImageResource(notification.getImageID());
if (notification.getIsDelivered())
singleNotificationLayout.setBackgroundColor(Color.parseColor("#6d6d6d"));
else
singleNotificationLayout.setBackgroundColor(Color.parseColor("#FF40459A"));
return customView;
}
}
here is the log:
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:501)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:354)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
at android.content.res.Resources.loadDrawable(Resources.java:1970)
at android.content.res.Resources.getDrawable(Resources.java:660)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.TintManager.getDrawable(TintManager.java:175)
at android.support.v7.widget.TintManager.getDrawable(TintManager.java:168)
at android.support.v7.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:51)
at android.support.v7.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:72)
at android.widget.AbsListView.obtainView(AbsListView.java:2143)
at android.widget.ListView.makeAndAddView(ListView.java:1831)
at android.widget.ListView.fillDown(ListView.java:674)
at android.widget.ListView.fillSpecific(ListView.java:1332)
at android.widget.ListView.layoutChildren(ListView.java:1630)
at android.widget.AbsListView.onLayout(AbsListView.java:1994)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1021)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1037)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:747)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1156)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:760)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1663)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1521)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:14008)
at android.view.ViewGroup.layout(ViewGroup.java:4373)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1892)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1711)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
So the problem as you can see is in your adapter (at com...timesavvi.CustomeAdapter.getView(CustomeAdapter.java:36)).
The culprit would seem to be logoImage.setImageResource(notification.getImageID()); (which I assume is ln 36)
What this will mean is the image to which getImageID points is a very large file which is not suitable for the device. You should use scaled images for the various densities and not use particularly large dimensions in order to avoid this issue.
Bear in mind as well that in an adpater any code you write can be called dozens of times, depending on how many rows you have in your recycler/list view and that if you are decoding from a network resource, it may continue to do that in the background for rows which arent even on the screen any more, so you need to manage such calls if you use them