[Solved] Comparing String (index) [duplicate]

From what I understand, you want to compare two arrays that might not be the same size, and if they are not, then only compare up to the shortest size? You can do something like this: boolean equals = true; for(int i = 0; i < test1.length && i < test2.length; i++) { if(!test1[i].equals(test2[i])) { … Read more

[Solved] How to make title bar in android App [closed]

This can be done with the built-in ActionBar. I Recommend following the tutorials on googles website. Also you should know that the native ActionBar requires API level 11, so if you’re interested in a very high compatibility, you need to use a library like ActionBarSherlock. solved How to make title bar in android App [closed]

[Solved] Eclipse autocomplete view became wide and block the whole screen [closed]

Eclipse could be remembering the size of the dialog for content assist UI in the workspace/.metadata directory. Try editing this file: <workspace_dir>/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml Look for the section that looks like this: <section name=”completion_proposal_size”> </section> In my workspace there is no special settings here, but perhaps there are some special settings in your workspace. 1 solved Eclipse … Read more

[Solved] Why does my View.findViewById return null?

mLanguageLogoImageView = itemView.findViewById(R.id.language_logo); mLanguageNameTextView = itemView.findViewById(R.id.language_name); mLanguageRankTextView = itemView.findViewById(R.id.language_rank); NullPointerException is thrown when an application attempts to use an object reference that has the null value. At first check your all findViewById elements present in respective xml (R.layout.list_item_language) or not. 0 solved Why does my View.findViewById return null?

[Solved] Map and Cardview Activities

Here is the example of what you are trying to achieve: Libraries required: compile ‘com.github.ksoichiro:android-observablescrollview:1.5.0’ compile ‘com.nineoldandroids:library:2.4.0’ Sample XML code: <?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” app:layout_behavior=”@string/appbar_scrolling_view_behavior” tools:showIn=”@layout/activity_main”> <com.github.ksoichiro.android.observablescrollview.ObservableScrollView android:id=”@+id/scroll” android:layout_width=”match_parent” android:layout_height=”match_parent” android:fillViewport=”true”> <RelativeLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:gravity=”center_horizontal|start”> <!– YOUR MAP FRAGMENT HERE –> <ImageView android:id=”@+id/image” android:layout_width=”match_parent” android:layout_height=”@dimen/parallax_image_height” android:layout_gravity=”top” android:scaleType=”centerCrop” android:src=”https://stackoverflow.com/questions/45178569/@drawable/putin” /> <View … Read more

[Solved] How to retrieve previous button state when start application again?

try this SharedPreferences sp=getSharedPreferences(“Button”, Context.MODE_PRIVATE); SharedPreferences.Editor Ed=sp.edit(); // get status of button to set backround from SharedPreferences in oncrate() methosd if(sp.getBoolean(“button1”,false)){ b1.setBackgroundColor(Color.WHITE); }else { b1.setBackgroundColor(Color.GREEN); } if(sp.getBoolean(“button2”,false)){ b2.setBackgroundColor(Color.WHITE); }else { b2.setBackgroundColor(Color.GREEN); } // set button background status in SharedPreferences b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { b1.setBackgroundColor(Color.GREEN); b2.setBackgroundColor(Color.WHITE); Ed.putBoolean(“button1”, true); Ed.commit(); } } … Read more

[Solved] I’m noob here. Need a little help to add values on EditText

Try using setOnClickListener to listen to click events import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; public class MainActivity extends AppCompatActivity { EditText abasic, ahra, aca, lopfd, lophd, la; TextView ebasic, ehra, eca, agross, egross, loprs, hdrs, lars, td, spd, eepf, erpf, tpf, eeesi, eresi, tesi, pfesi; … Read more

[Solved] How can I add two button (one is back, one is next) under scrollview that filled with textview and imageview in a screen, android?

This is what XML is for. Create your layout in xml and import it via java. You will want to create your own “bar layout” for the bars in the center, though you could I suppose, fill 3 separate LinearLayouts to achieve the same effect, making a separate layout and putting in it here will … Read more

[Solved] Compiler does not recognize button

The Button and View classes need to be imported; e.g. import android.widget.Button; import android.view.View; Your class is in the default package, so all classes that it uses (apart from those in the java.lang package) need to be imported. The reference to button_id is probably a mistake. Button mButton = (Button) findViewById(R.id.button); final Button button = … Read more

[Solved] Loop is infinitly looping or IndexOutOfBoundsException: Index =4, Size =2

You are getting IndexOutOfBoundsException on restrictedAreaArrayList, You are adding imageInfos to restrictedAreaArrayList with restrictedAreaArrayList.add(i,imageInfos); ith index may not exist in restrictedAreaArrayList you can just add it restrictedAreaArrayList.add(imageInfos) Or if you want to preserve the order then make restrictedAreaArrayList’s size equal to imageInfosArrayList you can do that by creating it with restrictedAreaArrayList = new ArrayList<ImageInfos>(imageInfosArrayList.size()); Or … Read more

[Solved] My app is crashing when I switch to dark mode

You’re casting the nullable Activity to a non-null Context in a listener that might be called when the Fragment it no longer attached to an Activity, which means the Activity would be null at that point. You should generally avoid casting with as. In this case, it masks what the problem was. At least if … Read more

[Solved] How to make a magnetic feild intensity measurer app in Android – Java [closed]

If you want the values of all axis from the Magnetometer this will do it. (By default the values is in microTesla) public class MagnetActivity extends AppCompatActivity implements SensorEventListener{ private SensorManager sensorManager; sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); @Override public void onSensorChanged(SensorEvent event) { if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) { int x_value = event.values[0]; int y_value = event.values[1]; … Read more