Resources$NotFoundException: File res/drawable-anydpi-v21/ic_upsc.xml - java

i have created an app by using SVG and PNG Images it is perfectly working in android 5.1 and android 6.0 but other other version like android 4.4, 7.1 and 8.1 application crash and show me this error:
Fatal exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ejobbox.ejobbox/com.ejobbox.ejobbox.DrawerMenu}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class ImageView
FATAL EXCEPTION: main
Process: com.ejobbox.ejobbox, PID: 8648
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ejobbox.ejobbox/com.ejobbox.ejobbox.DrawerMenu}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class ImageView
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
Caused by: android.content.res.Resources$NotFoundException: Drawable com.ejobbox.ejobbox:drawable/ic_upsc with resource ID #0x7f0700a2
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-anydpi-v21/ic_upsc.xml from drawable resource ID #0x7f0700a2
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
I am currently using android studio 3.0 version so please let me know how can i fix it. i have added
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
but the error is not fixed, so please help me to resolve this error.
activity_drawer_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawermenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ejobbox.ejobbox.DrawerMenu">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/backgroundcolor"
android:orientation="vertical"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="4">
<android.support.v7.widget.CardView
android:id="#+id/card_add1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="?attr/cardbackground">
<LinearLayout
android:id="#+id/LayerImg1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="?attr/cardbackground"
android:gravity="center"
android:orientation="vertical"
android:padding="2dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/img1"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#drawable/border"
android:padding="5dp"
android:src="#drawable/ic_letestjob" />
<TextView
android:id="#+id/badgeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/img1"
android:layout_alignTop="#+id/img1"
android:layout_marginRight="-2dip"
android:layout_marginTop="-2dip"
android:background="#drawable/item_count"
android:gravity="center"
android:textColor="#FFF"
android:textSize="10sp"
android:textStyle="bold"
android:text="10"
android:visibility="visible" />
</RelativeLayout>
<TextView
android:id="#+id/ltsjobs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/img1"
android:layout_marginTop="-10dp"
android:background="#drawable/txtborder"
android:gravity="center"
android:paddingBottom="1dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="1dp"
android:text="Latest Jobs"
android:textColor="?attr/icontextcolor"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/BankingIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="?attr/cardbackground">
<LinearLayout
android:id="#+id/LayerBanking"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="?attr/cardbackground"
android:gravity="center"
android:orientation="vertical"
android:padding="2dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/BankingLogo"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#drawable/border"
android:padding="5dp"
android:src="#drawable/ic_banking" />
<TextView
android:id="#+id/BankingBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/BankingLogo"
android:layout_alignTop="#+id/BankingLogo"
android:layout_marginRight="-2dip"
android:layout_marginTop="-2dip"
android:background="#drawable/item_count"
android:gravity="center"
android:textColor="#FFF"
android:textSize="11sp"
android:textStyle="bold"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="#+id/BankingTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/BankingLogo"
android:layout_marginTop="-10dp"
android:background="#drawable/txtborder"
android:gravity="center"
android:paddingBottom="1dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="1dp"
android:text="Banking"
android:textColor="?attr/icontextcolor"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/PoliceIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:layout_weight="1"
android:background="?attr/cardbackground">
<LinearLayout
android:id="#+id/LayerPolice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="?attr/cardbackground"
android:gravity="center"
android:orientation="vertical"
android:padding="2dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp">
<ImageView
android:id="#+id/PoliceLogo"
android:layout_width="60dp"
android:layout_height="60dp"
android:background="#drawable/border"
android:padding="5dp"
android:src="#drawable/ic_police" />
<TextView
android:id="#+id/PoliceBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/PoliceLogo"
android:layout_alignTop="#+id/PoliceLogo"
android:layout_marginRight="-2dip"
android:layout_marginTop="-2dip"
android:background="#drawable/item_count"
android:gravity="center"
android:textColor="#FFF"
android:textSize="11sp"
android:textStyle="bold"
android:visibility="gone" />
</RelativeLayout>
<TextView
android:id="#+id/PoliceTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/PoliceLogo"
android:layout_marginTop="-10dp"
android:background="#drawable/txtborder"
android:gravity="center"
android:paddingBottom="1dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="1dp"
android:text="Police"
android:textColor="?attr/icontextcolor"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigationMenuView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="?attr/backgroundcolor"
app:headerLayout="#layout/header"
app:itemIconTint="?attr/tintcolor"
app:itemTextColor="?attr/textcolor"
app:menu="#menu/drawermenu">
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
DrawerMenu.java
package com.ejobbox.ejobbox;
import android.app.Activity;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.renderscript.Sampler;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.CardView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.ShareActionProvider;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import com.ejobbox.ejobbox.Helper.LocalHelper;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.google.android.gms.ads.MobileAds;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.crash.FirebaseCrash;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import cc.cloudist.acplibrary.ACProgressConstant;
import cc.cloudist.acplibrary.ACProgressPie;
import in.galaxyofandroid.spinerdialog.OnSpinerItemClick;
import in.galaxyofandroid.spinerdialog.SpinnerDialog;
import io.paperdb.Paper;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class DrawerMenu extends AppCompatActivity implements View.OnClickListener {
private ArrayList<Model> list;
private String baseURL = "http://ejobbox.com/";
private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mToggle;
private NavigationView navMenuView;
SharedPreferences sharedPreferences;
private FirebaseAnalytics mFirebaseAnalytics;
Context context;
boolean doubleBackToExitPressed = false;
SharedPref sharedpref;
SharedPref Languagepref;
private float cVersion;
private String Applink;
private boolean is_first=true;
private String cVer;
private Menu menu;
ArrayList<String> items = new ArrayList<>();
ArrayList<String> Qualiitems = new ArrayList<>();
SpinnerDialog spinnerDialog;
SpinnerDialog spinnerDialogQuali;
ImageView imageView;
int GetMenuid;
public static final String PREFS_NAME = "Datakey";
public static final String PREFS_NAME2 = "Updatekey";
private CardView BtnAdd1, BtnAdd2, BtnAdd3, BtnAdd4, BtnAdd5, BtnAdd6, BtnAdd7, BtnAdd8, BtnAdd9, BtnAdd10, BtnAdd11, BtnAdd12, BtnAdd13, BtnAdd14, BtnAdd15, BtnAdd16, BtnAdd17, BtnAdd18;
int getBadgedataInt;
int getOLDVALUEInt;
int jobResponseValue;
int ResultUpd = 0;
int BankingValue;
int getBankingOLD;
int BankingResult = 0;
int ResultValue, AdmitCardValue, PoliceValue, RailwayValue, SscValue, UpscValue, DefenceValue, ITComputerValue, EngereeningValue, MedicalValue, SPSCValue, ITIValue, TeacherValue, InterviewValue, AdmitionValue, OtherjobValue;
int getResultOLD, getAdmitCardOLD, getPoliceOLD, getRailwayOLD, getSscOLD, getUpscOLD, getITComputerOLD, getDefenceOLD, getEngereeningOLD, getMedicalOLD, getSPSCOLD, getITIOLD, getTeacherOLD, getInterviewOLD, getAdmitionOLD, getOtherjobOLD;
int ResultResult = 0, AdmitResult = 0, PoliceResult = 0, RailwayResult = 0, SscResult = 0, UpscResult = 0, ITComputerResult = 0, DefenceResult = 0, EngereeningResult = 0, MedicalResult = 0, ITIResult = 0, SPSCResult = 0, TeacherResult = 0, InterviewResult = 0, AdmitionResult = 0, OtherjobResult = 0;
TextView ltsJobs, TextLang, BankingTxt, PoliceTxt, RailwayTxt, Ssctxt, UpscTxt, ITItxt, DefenceTxt, ITTxt, Teachertxt, InterviewTxt, AdmitionTxt, EngerTxt, MedicalTxt, spscTxt, OtherTxt, ResultTxt, AdmitTxt,StateTxt,QualiTxt;
private AdView mAdView;
#Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(LocalHelper.onAttach(newBase, "en"));
}
#Override
protected void onCreate(Bundle savedInstanceState) {
sharedpref = new SharedPref(this);
if (sharedpref.loadNightModeState() == true) {
setTheme(R.style.darktheme);
} else setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer_menu);
android.widget.Toolbar toolbar=(android.widget.Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("EJOBBOX");
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
checkInternetConenction();
//TODO:Google ADS sense
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// todo: Obtain the FirebaseAnalytics instance.
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
mFirebaseAnalytics.setMinimumSessionDuration(20000);
final TextView badge = (TextView) findViewById(R.id.badgeCount);
final TextView Banking = (TextView) findViewById(R.id.BankingBadge);
final TextView Railway = (TextView) findViewById(R.id.RailwayBadge);
final TextView Police = (TextView) findViewById(R.id.PoliceBadge);
final TextView SSC = (TextView) findViewById(R.id.SscBadge);
final TextView UPSC = (TextView) findViewById(R.id.UpscBadge);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawermenu);
mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.open, R.string.close);
mDrawerLayout.addDrawerListener(mToggle);
navMenuView = (NavigationView) findViewById(R.id.navigationMenuView);
mToggle.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
BtnAdd1 = (CardView) findViewById(R.id.card_add1);
BtnAdd2 = (CardView) findViewById(R.id.BankingIcon);
BtnAdd3 = (CardView) findViewById(R.id.PoliceIcon);
BtnAdd4 = (CardView) findViewById(R.id.RailwayIcon);
BtnAdd5 = (CardView) findViewById(R.id.SscIcon);
BtnAdd6 = (CardView) findViewById(R.id.UpscIcon);
//add Click Listner
BtnAdd1.setOnClickListener(this);
BtnAdd2.setOnClickListener(this);
BtnAdd3.setOnClickListener(this);
BtnAdd4.setOnClickListener(this);
BtnAdd5.setOnClickListener(this);
BtnAdd6.setOnClickListener(this);
sharedPreferences = getSharedPreferences(PREFS_NAME, 0);
final SharedPreferences.Editor editors = sharedPreferences.edit();
navMenuView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem item) {
Intent MenuIntent;
switch (item.getItemId()) {
case R.id.Alljobs:
MenuIntent = new Intent(DrawerMenu.this, AllJobsPage.class);
MenuIntent.putExtra("UpdResult", String.valueOf(jobResponseValue));
MenuIntent.putExtra("jobID", "190");
MenuIntent.putExtra("JOBSSTATE", R.string.All_jobs);
startActivity(MenuIntent);
break;
case R.id.countdown:
MenuIntent = new Intent(DrawerMenu.this, ExamCountdown.class);
startActivity(MenuIntent);
break;
case R.id.jobsummary:
MenuIntent = new Intent(DrawerMenu.this, JobSummary.class);
startActivity(MenuIntent);
break;
default:
break;
}
return false;
}
});
//TODO: Check Internet Connection [End]
private void initItems() {
for (int i = 0; i < 1; i++) {
items.add(this.getResources().getString(R.string.All_india));
items.add(this.getResources().getString(R.string.AndraPradesh));
items.add(this.getResources().getString(R.string.ArunachalPrades));
items.add(this.getResources().getString(R.string.Assam));
items.add(this.getResources().getString(R.string.Bihar));
}
}
private void eduQulification() {
for (int i = 0; i < 1; i++) {
Qualiitems.add(this.getResources().getString(R.string.ssc));
Qualiitems.add(this.getResources().getString(R.string.hsc));
Qualiitems.add(this.getResources().getString(R.string.Diploma));
Qualiitems.add(this.getResources().getString(R.string.ITI));
Qualiitems.add(this.getResources().getString(R.string.Graduate));
}
}
// Searching With Spinner[END]
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (mToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void onClick(View v) {
GetMenuid= v.getId();
Intent i;
// i = new Intent(this, police.class);
switch (v.getId()) {
case R.id.card_add1:
i = new Intent(this, AllJobsPage.class);
i.putExtra("UpdResult", String.valueOf(jobResponseValue));
i.putExtra("jobID", "190");
i.putExtra("JOBSSTATE", R.string.All_jobs);
startActivity(i);
break;
case R.id.BankingIcon:
i = new Intent(this, police.class);
i.putExtra("BankingUPD",String.valueOf(BankingValue));
i.putExtra("jobID","197");
i.putExtra("JOBSSTATE",this.getResources().getString(R.string.Banking_Jobs));
startActivity(i);
break;
case R.id.PoliceIcon:
i = new Intent(this, police.class);
i.putExtra("PoliceUPD",String.valueOf(PoliceValue));
i.putExtra("jobID","198");
i.putExtra("JOBSSTATE",this.getResources().getString(R.string.Police_Jobs));
startActivity(i);
break;
default:
break;
}
}
private void setSupportActionBar(android.widget.Toolbar toolbar) {
if(getSupportActionBar()!=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
}
//TODO: Actionbar Share Button
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.memu_items,menu);
MenuItem menushare=menu.findItem(R.id.sharMenu);
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menushare);
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,DrawerMenu.this.getResources().getString(R.string.shareTitle));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, DrawerMenu.this.getResources().getString(R.string.shareContent)+"\n"+DrawerMenu.this.getResources().getString(R.string.applink));
mShareActionProvider.setShareIntent(sharingIntent);
return true;
}
}

move all drawables located in the folder "/res/drawable-anydpi-v21" into the normal drawable folder.
See also error message line:
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-anydpi-v21/ic_upsc.xml from drawable resource ID #0x7f0700a2
To support the different resolutions of image files, it is best to use the following folders:
drawable-ldpi
drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxhdpi
Hope that could solve your problem

Related

Android Equalizer is not working after leaving the Equalizer Activity

Hope you are doing well.
I am tryring to create a Music Player Application where i am using the below pre-created equalizer package from GitHub.
https://github.com/bullheadandplato/AndroidEqualizer
The issue is,as soon as i am leaving the Equalizer activity, music is playing in normal way and equalizer effetcs are stopping.
I tried to created a service but no luck.
My code for Music Player View
package com.subhrajit.omegamusicplayer;
import static com.subhrajit.omegamusicplayer.AllTracksAdapter.convertTimeMMSS;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.media.audiofx.AudioEffect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import com.bullhead.equalizer.DialogEqualizerFragment;
import com.bullhead.equalizer.EqualizerFragment;
import com.bumptech.glide.Glide;
import com.chibde.visualizer.BarVisualizer;
import com.chibde.visualizer.SquareBarVisualizer;
import java.io.IOException;
import java.util.ArrayList;
import de.hdodenhof.circleimageview.CircleImageView;
public class MusicPlayerView extends AppCompatActivity {
SquareBarVisualizer barVisualizer;
Toolbar playerToolBar;
LinearLayout mainPlayer;
ImageView pausePlay, next, previous,repeat,shuffle,lovedSong;
CircleImageView albumArt;
TextView songName,songStart,songTotalTime;
SeekBar songDuration;
ArrayList<Song> songList=new ArrayList<>();
Song currentSong;
static MediaPlayer mediaPlayer=PlayerInstance.getInstance();
int x=0; //To set Rotation
Context context;
Song nowPlaying;
#SuppressLint("WrongViewCast")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music_player_view);
context=getApplication().getApplicationContext();
//Top Parent ViewGroup
mainPlayer=findViewById(R.id.playerMainLayout);
//Toolbar of Play Activity
playerToolBar=findViewById(R.id.musicPlayerToolBar);
//Album Art of Song
albumArt=findViewById(R.id.imgAlbumArt);
//Loved Song
lovedSong=findViewById(R.id.lovedSong);
//AllButtons
pausePlay=findViewById(R.id.btnPlayPause);
next=findViewById(R.id.btnNext);
previous=findViewById(R.id.btnBack);
repeat=findViewById(R.id.btnRepeat);
shuffle=findViewById(R.id.btnShuffle);
shuffle.setSelected(false);
//Song Seekbar
songDuration=findViewById(R.id.songProgress);
//Text Views to show Song information while playing
songName=findViewById(R.id.songName);
songName.setSelected(true);
songTotalTime=findViewById(R.id.songTotalTime);
songStart=findViewById(R.id.songStartTime);
//Visualizer Position Set
barVisualizer=findViewById(R.id.barVisualizer);
// set custom color to the line.
barVisualizer.setColor(ContextCompat.getColor(this, R.color.secondary_color));
// define custom number of bars you want in the visualizer between (10 - 256).
barVisualizer.setDensity(18);
// Set Spacing
barVisualizer.setGap(5);
//Setting Player Activity Toolbar
setSupportActionBar(playerToolBar);
getSupportActionBar().setTitle("Now Playing");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
//Fetching Data From Adapter to this activity
songList=((ArrayList<Song>)getIntent().getSerializableExtra("Songs"));
if (songList!=null){
setDataWithMusic();
}else{
Toast.makeText(this,"Null Data",Toast.LENGTH_LONG).show();
}
//Setting Selected Song Part
lovedSong.setOnClickListener(v->{
if (!songList.get(PlayerInstance.currentIndex).isLoved()){
songList.get(PlayerInstance.currentIndex).setLoved(true);
lovedSong.setImageResource(R.drawable.after_heart);
}else{
songList.get(PlayerInstance.currentIndex).setLoved(false);
lovedSong.setImageResource(R.drawable.before_heart);
}
});
//Declaring New Thread so that Seekbar and progress value can be changed realtime
MusicPlayerView.this.runOnUiThread(new Runnable() {
#Override
public void run() {
if (mediaPlayer!=null){
songDuration.setProgress(mediaPlayer.getCurrentPosition());
songStart.setText(convertTimeMMSS(String.valueOf(mediaPlayer.getCurrentPosition())));
albumArt.setRotation(x++);
if (mediaPlayer.isPlaying()){
pausePlay.setImageResource(R.drawable.pause);
}else{
pausePlay.setImageResource(R.drawable.play);
albumArt.setRotation(0);
}
}
new Handler().postDelayed(this,100);
}
});
//Setting Music Seekbar to work
songDuration.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
#Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (mediaPlayer != null && fromUser){
mediaPlayer.seekTo(progress);
}
}
#Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
#Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
public int setDataWithMusic() {
currentSong = songList.get(PlayerInstance.currentIndex);
nowPlaying=songList.get(PlayerInstance.currentIndex);
//Setting AlbumArt
byte[]art=getAlbumArt(currentSong.getPath());
if (art!=null){
Glide.with(context.getApplicationContext()).asBitmap()
.load(art)
.into(albumArt);
}else{
Glide.with(getApplicationContext()).asBitmap()
.load(R.drawable.default_albumart)
.into(albumArt);
}
songName.setText(currentSong.getTitle());
songTotalTime.setText(convertTimeMMSS(currentSong.getDuration()));
songStart.setText("00:00");
pausePlay.setOnClickListener(v->pausePlayMusic());
previous.setOnClickListener(v->previousMusic());
next.setOnClickListener(v->nextMusic());
repeat.setOnClickListener(v->{
if (mediaPlayer.isLooping()){
repeat.setImageResource(R.drawable.before_repeat);
mediaPlayer.setLooping(false);
}else{
repeat.setImageResource(R.drawable.after_repeat);
mediaPlayer.setLooping(true);
}
});
shuffle.setOnClickListener(v->{
});
try{
playMusic();
}catch (Exception ex){
Log.e("Error",ex.toString());
}
return PlayerInstance.currentIndex;
}
//AlbumArt Retriever Method
public byte[] getAlbumArt(String uri){
MediaMetadataRetriever retriever=new MediaMetadataRetriever();
retriever.setDataSource(uri);
byte[]art=retriever.getEmbeddedPicture();
retriever.release();
return art;
}
private void playMusic() throws IOException {
mediaPlayer.reset();
mediaPlayer.setDataSource(currentSong.getPath());
mediaPlayer.prepare();
mediaPlayer.start();
songDuration.setProgress(0);
songDuration.setMax(mediaPlayer.getDuration());
//To play songs after completion if available
mediaPlayer.setOnCompletionListener(v->{
nextMusic();
});
barVisualizer.setPlayer(mediaPlayer.getAudioSessionId());
}
private void nextMusic() {
if (PlayerInstance.currentIndex==songList.size()-1 || mediaPlayer.isLooping()){
return;
}
PlayerInstance.currentIndex+=1;
mediaPlayer.reset();
setDataWithMusic();
}
private void previousMusic() {
if (PlayerInstance.currentIndex==0 || mediaPlayer.isLooping()){
return;
}
PlayerInstance.currentIndex-=1;
mediaPlayer.reset();
setDataWithMusic();
}
private void pausePlayMusic() {
if (mediaPlayer.isPlaying()){
mediaPlayer.pause();
}else{
mediaPlayer.start();
}
}
#Override
public boolean onCreateOptionsMenu(#NonNull Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.music_player_toolbar_menu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(#NonNull MenuItem item) {
switch(item.getItemId()){
case R.id.showEQ:
startService(new Intent(getApplicationContext(),EqualizerService.class));
getSupportFragmentManager().beginTransaction()
.replace(R.id.eqFrame,new EqualizerService().getEqualizerFragment())
.commit();
//startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
}
My code to implement Equalizer as a service
package com.subhrajit.omegamusicplayer;
import android.app.Service;
import android.content.Intent;
import android.graphics.Color;
import android.os.IBinder;
import androidx.annotation.Nullable;
import com.bullhead.equalizer.EqualizerFragment;
public class EqualizerService extends Service {
EqualizerFragment equalizerFragment;
public EqualizerFragment getEqualizerFragment(){
equalizerFragment = EqualizerFragment.newBuilder()
.setAccentColor(Color.parseColor("#4caf50"))
.setAudioSessionId(PlayerInstance.getInstance().getAudioSessionId())
.build();
return equalizerFragment;
}
#Nullable
#Override
public IBinder onBind(Intent intent) {
return null;
}
#Override
public int onStartCommand(Intent intent, int flags, int startId) {
getEqualizerFragment();
return START_STICKY;
}
}
MusicPlayerView.xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/playerMainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/black"
tools:context=".MusicPlayerView">
<include layout="#layout/music_player_toolbar" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/eqFrame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
</FrameLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/songName"
android:layout_width="match_parent"
android:layout_height="60dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="TextView"
android:textColor="#color/white"
android:textSize="30dp"
android:textStyle="italic" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/imgAlbumArt"
android:layout_width="wrap_content"
android:layout_height="234dp"
android:layout_margin="20dp"
android:src="#drawable/profile"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp" />
<ImageView
android:id="#+id/lovedSong"
android:layout_width="match_parent"
android:layout_height="43dp"
app:srcCompat="#drawable/before_heart" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_marginTop="30dp"
android:orientation="horizontal" >
<ImageView
android:id="#+id/btnShuffle"
android:layout_width="70dp"
android:layout_height="match_parent"
android:defaultFocusHighlightEnabled="true"
app:srcCompat="#drawable/shuffle" />
<ImageView
android:id="#+id/btnBack"
android:layout_width="70dp"
android:layout_height="match_parent"
android:defaultFocusHighlightEnabled="true"
app:srcCompat="#drawable/back" />
<ImageView
android:id="#+id/btnPlayPause"
android:layout_width="70dp"
android:layout_height="match_parent"
android:defaultFocusHighlightEnabled="true"
app:srcCompat="#drawable/pause" />
<ImageView
android:id="#+id/btnNext"
android:layout_width="70dp"
android:layout_height="match_parent"
android:defaultFocusHighlightEnabled="true"
app:srcCompat="#drawable/next" />
<ImageView
android:id="#+id/btnRepeat"
android:layout_width="70dp"
android:layout_height="match_parent"
android:defaultFocusHighlightEnabled="true"
app:srcCompat="#drawable/before_repeat" />
</LinearLayout>
<SeekBar
android:id="#+id/songProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginTop="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginStart="14dp"
android:orientation="horizontal">
<TextView
android:id="#+id/songStartTime"
android:layout_width="147dp"
android:layout_height="49dp"
android:layout_marginEnd="110dp"
android:textColor="#color/white"
android:layout_weight="5"
android:textStyle="bold"
android:text="TextView"
android:textSize="20dp" />
<TextView
android:id="#+id/songTotalTime"
android:layout_width="wrap_content"
android:layout_height="49dp"
android:layout_weight="5"
android:textSize="20dp"
android:textColor="#color/white"
android:textStyle="bold"
android:text="TextView" />
</LinearLayout>
<com.chibde.visualizer.SquareBarVisualizer
android:id="#+id/barVisualizer"
android:layout_width="match_parent"
android:layout_height="250dp" >
</com.chibde.visualizer.SquareBarVisualizer>
</LinearLayout>
</ScrollView>
</LinearLayout>
Please help me here

Problems in Android FirebaseRecyclerView Implementing A Search Users Function

I'm looking to implement a search function. When it runs, logcat is telling me:
E/RecyclerView: No adapter attached; skipping layout.
I have searched SO and the net and the answers tell me that I need to set the adapter and the linear layout manager. As you will see with my code, I set both. Alex Mamo's (#AlexMamo) work on here seems to point me in the right direction but I'm still getting the error.
My Activity
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.MyApp.Objects.ParticipantsObject;
import com.MyApp.R;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
public class ParticipantsActivity extends AppCompatActivity {
private EditText mSearchField;
private ImageButton mSearchBtn;
private RecyclerView mResultList;
private DatabaseReference mUserDatabase;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_neighbors);
mUserDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child("Participants");
mSearchField = (EditText) findViewById(R.id.search_field);
mSearchBtn = (ImageButton) findViewById(R.id.search_btn);
mResultList = (RecyclerView) findViewById(R.id.result_list);
mResultList.setHasFixedSize(true);
mResultList.setLayoutManager(new LinearLayoutManager(this));
mSearchBtn.setOnClickListener(view -> {
String searchText = mSearchField.getText().toString();
firebaseUserSearch(searchText);
});
}
private void firebaseUserSearch(String searchText) {
Toast.makeText(ParticipantsActivity.this, "Started Search", Toast.LENGTH_LONG).show();
Query firebaseSearchQuery = mUserDatabase.orderByChild("name").startAt(searchText);
FirebaseRecyclerOptions<ParticipantsObject> firebaseRecyclerOptions = new FirebaseRecyclerOptions.Builder<ParticipantsObject>()
.setQuery(firebaseSearchQuery, ParticipantsObject.class)
.build();
class UserHolder extends RecyclerView.ViewHolder {
private TextView imageThumbTextView, nameTextView
UserHolder(View itemView) {
super(itemView);
imageThumbTextView = itemView.findViewById(R.id.profile_image);
nameTextView = itemView.findViewById(R.id.name_text);
}
void setUsers(ParticipantsObject participantsObject) {
String imageThumb = driverObject.getThumb_image();
imageThumbTextView.setText(imageThumb);
String name = participantsObject.getName();
nameTextView.setText(name);
}
}
FirebaseRecyclerAdapter<ParticipantsObject, UserHolder> firebaseRecyclerAdapter;
firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<ParticipantsObject, UserHolder>(firebaseRecyclerOptions) {
#Override
protected void onBindViewHolder(#NonNull UserHolder userHolder, int position, #NonNull ParticipantsObject participantsObject) {
userHolder.setUsers(participantsObject);
}
#Override
public UserHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_layout, parent, false);
return new UserHolder(view);
}
};
mResultList.setAdapter(firebaseRecyclerAdapter);
firebaseRecyclerAdapter.startListening();
}
}
My Activity XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
tools:context="com.MyApp.ParticipantsActivity">
<TextView
android:id="#+id/heading_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:text="Firebase Search"
android:textColor="#555555"
android:textSize="24sp" />
<EditText
android:id="#+id/search_field"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/heading_label"
android:layout_below="#+id/heading_label"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_toStartOf="#+id/search_btn"
android:background="#drawable/search_layout"
android:ems="10"
android:hint="Search here"
android:inputType="textPersonName"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:textColor="#999999"
android:textSize="16sp" />
<ImageButton
android:id="#+id/search_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/search_field"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/search_field"
android:layout_marginRight="30dp"
android:background="#android:color/background_light"
app:srcCompat="#mipmap/search_button" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/result_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/search_field"
android:layout_marginTop="50dp">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
My list layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/profile_image"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="20dp"
app:srcCompat="#mipmap/ic_default_user" />
<TextView
android:id="#+id/name_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="14dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="213dp"
android:layout_marginRight="20dp"
android:layout_toEndOf="#+id/profile_image"
android:text="Username"
android:textColor="#555555"
android:textSize="16sp" />
</RelativeLayout>
Any ideas or advice would be much appreciated.
Your code is setting the adapter only after a button is pushed. Because you didn't set it before the first time the RecyclerView needed to render itself on screen, it's going to warn you about that with the message you see in the log. The RecyclerView must have an adapter attached at the time of rendering in order for it to display anything.

ScrollView not scroll smoothly

I am developing online store application, i used bottom navigation menu and fragments to separate the pages of my online store , in my main fragment i have one scrollview that contains one image slider and two horizontal recycler views that used to show newest and special products.
every thing id good but
my really strange problem is that when i run application in my android phone the scrollview has really really bad performance, it scrolls really slowly and not smoothly.
i tried many ways to solve this problem ( but unfortunately none of them could solve my problem ) :
- i tried to remove image slider library
- i taught maybe images and bitmaps are the main cause of this bad performance but after i removed all images nothing changed !!!
and here is my code :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f6f6f6"
android:layoutDirection="rtl"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/slider_container"
android:layout_width="wrap_content"
android:layout_height="180dp">
<com.daimajia.slider.library.SliderLayout
android:id="#+id/slider"
android:layout_width="match_parent"
android:layout_height="180dp" />
<com.daimajia.slider.library.Indicators.PagerIndicator
android:id="#+id/custom_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<com.rd.PageIndicatorView
android:id="#+id/pageIndicatorView"
app:piv_animationType="worm"
app:piv_dynamicCount="true"
app:piv_interactiveAnimation="true"
app:piv_padding="8dp"
app:piv_radius="4dp"
app:piv_selectedColor="#color/golden_vip"
app:piv_unselectedColor="#d1d1d1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="15dp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/special_products_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="#f1f1f1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="10dp"
android:text="محصولات ویژه وی آی پی"
android:textColor="#444444"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="#drawable/volleyball" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/special_products_horizontal_recyclerview"
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_below="#+id/special_products_title"
android:isScrollContainer="false"
android:nestedScrollingEnabled="false" />
<RelativeLayout
android:id="#+id/new_products_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/special_products_horizontal_recyclerview"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="#f1f1f1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="10dp"
android:text="محصولات جدید وی آی پی"
android:textColor="#444444"
android:textSize="11sp"
android:textStyle="bold" />
</LinearLayout>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="#drawable/volleyball" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/new_products_horizontal_recyclerview"
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_marginBottom="700dp"
android:layout_below="#+id/new_products_title"
android:isScrollContainer="false"
android:nestedScrollingEnabled="false" />
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/loader"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.3"
android:background="#222222"
android:visibility="visible">
<ProgressBar
android:id="#+id/progress_load_categories"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/progress_load_categories"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="لطفا منتظر بمانید ..."
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
and here is my fragment :
package com.gladcherry.vipiranian.activityformain;
import android.app.Dialog;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.speech.RecognizerIntent;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.daimajia.slider.library.Animations.DescriptionAnimation;
import com.daimajia.slider.library.Indicators.PagerIndicator;
import com.daimajia.slider.library.SliderLayout;
import com.daimajia.slider.library.SliderTypes.BaseSliderView;
import com.daimajia.slider.library.SliderTypes.TextSliderView;
import com.daimajia.slider.library.Tricks.ViewPagerEx;
import com.github.amlcurran.showcaseview.OnShowcaseEventListener;
import com.github.amlcurran.showcaseview.ShowcaseView;
import com.github.amlcurran.showcaseview.targets.ViewTarget;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import com.github.mikephil.charting.utils.ColorTemplate;
import com.gladcherry.vipiranian.Adapter.CategoriesDataAdapter;
import com.gladcherry.vipiranian.Adapter.ProductsDataAdapter;
import com.gladcherry.vipiranian.MaterialSearchViewPersian;
import com.gladcherry.vipiranian.Model.CategoryModel;
import com.gladcherry.vipiranian.Model.DetailsProjectData;
import com.gladcherry.vipiranian.R;
import com.rd.PageIndicatorView;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
import static android.app.Activity.RESULT_OK;
import static android.content.Context.MODE_PRIVATE;
/**
* Created by gladcherry on 9/30/17.
*/
public class MainViPFragment extends Fragment
implements OnShowcaseEventListener {
ViewPagerEx.OnPageChangeListener
Toolbar mToolbar;
int level = 0;
GridView gridView;
private Button inviteButton;
private static String getCategoriesApiUrl;
private Dialog loader;
private Button ChangeCity, EditProfile;
private ShowcaseView sv;
private FragmentDrawer drawerFragment;
private MaterialSearchViewPersian searchView;
private ProgressBar loadCategories;
RequestQueue queue;
TextView textView;
List<CategoryModel> SliderImages;
//private PageIndicatorView pageIndicatorView;
//private SliderLayout sliderLayout;
private RelativeLayout Loader;
private List<DetailsProjectData> specialProducts = new ArrayList<>();
private List<DetailsProjectData> newProducts = new ArrayList<>();
private ProductsDataAdapter SpecialDataAdapter;
private ProductsDataAdapter NewDataAdapter;
private RecyclerView specialRecyclerView; private RecyclerView newRecyclerView;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflating view layout
View layout = inflater.inflate(R.layout.activity_store_categories, container, false);
makeJsonArrayRequest();
return layout;
}
public void createValidation(String title, String msg) {
final Dialog builder = new Dialog(getActivity(), R.style.PauseDialog);
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
builder.setTitle(title);
builder.setContentView(R.layout.dialogforvalidations);
TextView text = (TextView) builder.findViewById(R.id.error_msg);
text.setText(msg);
Button close_dialog = (Button) builder.findViewById(R.id.close_btn_dialog);
close_dialog.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
builder.dismiss();
}
});
// display dialog
builder.show();
}
private void makeJsonArrayRequest() {
// Get UserId if current user has been registered or logged in
String UserIdSplash = "";
SharedPreferences prefs = getActivity().getSharedPreferences("Authentication", MODE_PRIVATE);
String userId = prefs.getString("UserName", null);
if (userId != null) {
UserIdSplash = userId;
}
// Get UserId if current user has been registered or logged in
// Get Guest Guid if Guest has been logged in as guest before
String GuidSplash = "";
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("Authentication", MODE_PRIVATE);
final String Guid = sharedPreferences.getString("Guid", null);
if (Guid != null) {
GuidSplash = Guid;
}
// Get Guest Guid if Guest has been logged in as guest before
//OSPermissionSubscriptionState status = OneSignal.getPermissionSubscriptionState();
getCategoriesApiUrl = getResources().getString(R.string.base_url);
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, getCategoriesApiUrl, null,
new Response.Listener<JSONObject>() {
#Override
public void onResponse(JSONObject response) {
try {
String State = response.get("Status").toString();
if (!State.equals("1")) {
Loader.animate().alpha(0.0f).setDuration(500);
createValidation(" خطای سیستم ", response.get("Text").toString());
} else {
Loader.animate().alpha(0.0f).setDuration(500);
SliderImages = new ArrayList<>();
//pageIndicatorView.setCount(response.getJSONArray("Sliders").length());
for (int i = 0; i < response.getJSONArray("Sliders").length(); i++) {
SliderImages.add(
new CategoryModel(
response.getJSONArray("Sliders").getJSONObject(i).get("Image").toString(),
" وی آی پی | ViP ",
response.getJSONArray("Sliders").getJSONObject(i).get("Id").toString())
);
}
JSONArray SpecialProducts = response.getJSONArray("SpecialProducts");
for (int i = 0; i < SpecialProducts.length(); i++) {
JSONObject currentProduct = SpecialProducts.getJSONObject(i);
specialProducts.add(new DetailsProjectData(currentProduct.getString("Id"), currentProduct.getString("PersianName"), currentProduct.getString("Image"), currentProduct.get("UnitPrice").toString(), currentProduct.get("PriceWithDiscount").toString(), currentProduct.get("Discount").toString(), "", "", "", ""));
}
SpecialDataAdapter = new ProductsDataAdapter(getActivity(), specialProducts);
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
specialRecyclerView = (RecyclerView) getActivity().findViewById(R.id.special_products_horizontal_recyclerview);
specialRecyclerView.setLayoutManager(layoutManager);
specialRecyclerView.setAdapter(SpecialDataAdapter);
specialRecyclerView.setNestedScrollingEnabled(false);
JSONArray NewProducts = response.getJSONArray("NewestProducts");
for (int i = 0; i < NewProducts.length(); i++) {
JSONObject currentProduct = NewProducts.getJSONObject(i);
newProducts.add(new DetailsProjectData(currentProduct.getString("Id"), currentProduct.getString("PersianName"), currentProduct.getString("Image"), currentProduct.get("UnitPrice").toString(), currentProduct.get("PriceWithDiscount").toString(), currentProduct.get("Discount").toString(), "", "", "", ""));
}
NewDataAdapter = new ProductsDataAdapter(getActivity(), newProducts);
LinearLayoutManager newlayoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
newRecyclerView = (RecyclerView) getActivity().findViewById(R.id.new_products_horizontal_recyclerview);
newRecyclerView.setLayoutManager(newlayoutManager);
newRecyclerView.setAdapter(NewDataAdapter);
newRecyclerView.setNestedScrollingEnabled(false);
}
}
catch (Exception ex)
{
if (ex.getMessage() != null) {
Log.d("exception", ex.getMessage());
}
Loader.animate().alpha(0.0f).setDuration(500);
}
}
}, new Response.ErrorListener()
{
#Override
public void onErrorResponse(VolleyError error) {
if (error != null && error.getMessage() != null) {
Log.w("VolleyError", error.getMessage());
VolleyLog.d(this.getClass().getSimpleName(), "Error: " + error.getMessage());
}
//loadCategories.setVisibility(View.GONE);
createValidation("پیام سیستم", "لطفا اتصال اینترنت خود را بررسی نمایید .");
}
});
request.setRetryPolicy(new
DefaultRetryPolicy(10000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
queue = Volley.newRequestQueue(getActivity().getApplicationContext());
queue.add(request);
}
#Override
public void onShowcaseViewHide(ShowcaseView showcaseView) {
}
#Override
public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
}
#Override
public void onShowcaseViewShow(ShowcaseView showcaseView) {
}
#Override
public void onShowcaseViewTouchBlocked(MotionEvent motionEvent) {
}
}
the problem was because of 2 lines that i was added to the manifest to prevent from android out of memory exception ...
remove these two lines and every thing well be ok :
android:largeHeap="true"
android:hardwareAccelerated="false"
i hope this answer going to help you ...
do the height of relative layout ="wrap_content" instead of match parent , also of scrollview.

XML files contain code, but preview is blank

so i have a project where im implementing a google sign in, i followed this tutorial on how to do that, but when i did, all my XML files appear blank. i made changes to the original MainActivity.java and the activity_main.xml file. i woudl think that only the activity_main.xml would be affected, but all of my XML files appear blank. when i try to run the app, i get
"Error:Content is not allowed in prolog.
" and
"Execution failed for task '.app:builderInfoDebugLoader'"
this is my activity main where i implement the google sign in:
package com.example.mayankthakur.personalprojecttrial2;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.auth.api.signin.SignInAccount;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity implements View.OnClickListener, GoogleApiClient.OnConnectionFailedListener {
private LinearLayout prof_section;
private Button SignOut;
private SignInButton SignIn;
private TextView Name,Email;
private ImageView Prof_Picture;
private Button continueBut;
private static final int REQ_CODE = 9001;
String name;
Intent nameSave;
private GoogleApiClient mGoogleApiClient;
public static final String prefsName = "com.example.mayankthakur.personalprojecttrial2";
private static final String TAG = "MainActivity";
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
prof_section = (LinearLayout) findViewById(R.id.prof_section);
SignOut = (Button) findViewById(R.id.logoutBtn);
SignIn = (SignInButton) findViewById(R.id.gSignIn);
Name = (TextView) findViewById(R.id.nameSpace);
Email = (TextView) findViewById(R.id.emailSpace);
Prof_Picture = (ImageView) findViewById(R.id.profilePicture);
continueBut = (Button) findViewById(R.id.button2);
continueBut.setOnClickListener(this);
SignOut.setOnClickListener(this);
SignIn.setOnClickListener(this) ;
prof_section.setVisibility(View.GONE);
continueBut.setVisibility(View.GONE);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
}
#Override
public void onClick (View v) {
switch (v.getId()) {
case R.id.gSignIn:
signIn();
break;
case R.id.logoutBtn:
signOut();
break;
/*// This is the shared preference
SharedPreferences.Editor prefs = getSharedPreferences(prefsName, MODE_PRIVATE).edit();
//adding a value to the preference
prefs.putString("name", name);
prefs.apply();
nameSave = new Intent(MainActivity.this, Activity2.class);
MainActivity.this.startActivity(nameSave);
*/
}
}
#Override
public void onConnectionFailed (#NonNull ConnectionResult connectionResult){
}
private void signIn() {
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, REQ_CODE );
}
private void signOut(){
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(new ResultCallback<Status>() {
#Override
public void onResult(#NonNull Status status) {
updateUI(false);
}
});
}
private void handleReuslt(GoogleSignInResult result){
if(result.isSuccess())
{
GoogleSignInAccount acct = result.getSignInAccount();
String personName = acct.getDisplayName();
String personEmail = acct.getEmail();
String imgUrl = acct.getPhotoUrl().toString();
String personId = acct.getId();
Uri personPhoto = acct.getPhotoUrl();
Name.setText(personName);
Email.setText(personEmail);
Glide.with(this).load(imgUrl).into(Prof_Picture);
updateUI(true);
}
else
{
updateUI(false);
}
}
private void updateUI(boolean isLogin){
if(isLogin)
{
prof_section.setVisibility(View.VISIBLE);
SignIn.setVisibility(View.GONE);
}
else
{
prof_section.setVisibility(View.GONE);
SignIn.setVisibility(View.VISIBLE);
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQ_CODE)
{
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleReuslt(result);
}
}
}
this is my XML file where i added the buttons and stuff for the google sign in:\
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/activity_main"
android:orientation="vertical"
tools:context="com.example.mayankthakur.personalprojecttrial2.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/prof_section"
android:layout_marginLeft="20dp"
android:layout_marginTop = "50dp"
android:weightSum="1">
<ImageView
android:id="#+id/profilePicture"
android:layout_width="90dp"
android:layout_height="100dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:src="#drawable/photo"
android:layout_weight="0.25" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="28dp"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/nameSpace"
android:layout_width="166dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:text="Name Display"
android:textSize="20dp"
android:textStyle="bold" />
<TextView
android:id="#+id/emailSpace"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Email Display"
android:textSize="14dp"
android:textStyle="bold" />
<Button
android:id="#+id/logoutBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Logout" />
</LinearLayout>
</LinearLayout>
<com.google.android.gms.common.SignInButton
android:id="#+id/gSignIn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="60dp">
</com.google.android.gms.common.SignInButton>
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please Sign in in order to make use of all of the features of the app"
android:textAlignment="center"
android:textSize="20dp"
android:layout_marginTop="30dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"/>
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
android:layout_marginTop="50dp"/>
</LinearLayout>
any help would be greatly appreciated, and if any of you require any more code please do ask
thanks in advance!

RuntimeException: Unable to start activity ComponentInfo: java.lang.NullPointerException Fatal exception

Hi i'm new to android programming and i'm having this issue where i'm sure that my code should work but doesn't.
This is my MainActivity.java:
package com.example.evo;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
public class MainActivity extends Activity {
ImageButton imageButton2;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.open);
imageButton2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SecondScreenActivity.class);
}
} );
}
}
This is my SeconScreenActirity.java
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
public class SecondScreenActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.high_score);
}
}
This is my highscore.xml layout file
<?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="match_parent"
android:background="#drawable/yedi"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="220dp"
android:text="high scores"
android:textColor="#FA5882" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="29dp"
android:text="Evrim"
android:textColor="#00FFFF" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="320dp"
android:layout_marginTop="-17dp"
android:text="1528"
android:textColor="#CC2EFA" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="20dp"
android:text="Selin"
android:textColor="#00FFFF" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="320dp"
android:layout_marginTop="-17dp"
android:text="1016"
android:textColor="#CC2EFA" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:layout_marginTop="11dp"
android:text="Muhammed"
android:textColor="#00FFFF" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="320dp"
android:layout_marginTop="-17dp"
android:text="800"
android:textColor="#CC2EFA" />
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="72dp"
android:layout_height="0dp"
android:layout_marginTop="80dp"
android:layout_weight="0.16"
android:src="#drawable/abc_ic_ab_back_holo_light"
android:contentDescription="#string/todo"/>
</LinearLayout>
This is my open.xml where i have my imageButton2
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/son"
android:paddingBottom="#dimen/activity_horizontal_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_horizontal_margin"
android:screenOrientation="landscape"
tools:context="com.example.kkk.MainActivity$PlaceholderFragment" >
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/highscore" android:contentDescription="#string/todo"/>
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_above="#+id/imageButton2"
android:layout_alignLeft="#+id/imageButton2"
android:src="#drawable/play" android:contentDescription="#string/todo"/>
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="#+id/imageButton3"
android:layout_centerHorizontal="true"
android:src="#drawable/exit" android:contentDescription="#string/todo"/>
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignLeft="#+id/imageButton2"
android:layout_below="#+id/imageButton2"
android:src="#drawable/aboutt" android:contentDescription="#string/todo"/>
</RelativeLayout>
I also updated my AndroidManifest.xml to add SeconScreenActivity.java
And i'm getting this
java.lang.RuntimeException: Unable to start activity
ComponentInfo java.lang.NullPointerException
errors please plase help!
You never initialize your imageButton element in your first activity.
So you get the NullPointerException when trying to assign to it the click listener.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.open);
//or whatever the id is for the image button in the open layout
imageButton2 = (ImageButton) findViewById(R.id.imageButton2);
imageButton2.setOnClickListener(new View.OnClickListener() {
You missed to take reference of ImageButton from open layout:
imageButton2 = (ImageButton) findViewById(R.id.<ImageButtonIdInOpenXml);
Just add below line
imageButton2 = (ImageButton)findViewById(R.id.imageButton1);
after
setContentView(R.layout.open);
Your are getting error because view ImageButton is not initialized

Categories