Android: How do I prevent the soft keyboard from pushing my view up?

You can simply switch your Activity’s windowSoftInputModeflag to adjustPan in your AndroidMainfest.xml file inside your activity tag. Check the official documentation for more info. <activity … android:windowSoftInputMode=”adjustPan”> </activity> If your container is not changing size, then you likely have the height set to “match parent”. If possible, set the parent to “Wrap Content”, or a … Read more

How to implement Android Pull-to-Refresh

Finally, Google released an official version of the pull-to-refresh library! It is called SwipeRefreshLayout, inside the support library, and the documentation is here: Add SwipeRefreshLayout as a parent of view which will be treated as a pull to refresh the layout. (I took ListView as an example, it can be any View like LinearLayout, ScrollView … Read more

Building and running app via Gradle and Android Studio is slower than via Eclipse

Hardware I’m sorry, but upgrading development station to SSD and tons of ram has probably a bigger influence than points below combined. Tools versions Increasing build performance has major priority for the development teams, so make sure you are using latest Gradle and Android Gradle Plugin. Configuration File Create a file named gradle.properties in whatever … Read more

Changing API level Android Studio

When you want to update your minSdkVersion in an existent Andriod project… Update build.gradle (Module: YourProject) under Gradle Script and make sure that it is NOT build.gradle (Project: YourProject.app). An example of build.gradle: apply plugin: ‘com.android.application’ android { compileSdkVersion 28 buildToolsVersion “28.0.2” defaultConfig { applicationId “com.stackoverflow.answer” minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName “1.0” } … Read more

How do I display the current value of an Android Preference in the Preference summary?

There are ways to make this a more generic solution, if that suits your needs. For example, if you want to generically have all list preferences show their choice as summary, you could have this for your onSharedPreferenceChanged implementation: public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { Preference pref = findPreference(key); if (pref instanceof ListPreference) { … Read more

Android Studio doesn’t see device [closed]

I recently had trouble with this, and regardless of what I did(restart adb, edit adb_usb.ini, restart computer+device+swap usb port, reinstall studio etc. etc.) I just couldnt get it to work, and could not even detect my device using ‘adb devices’. Finally after about 2 hours of googling and testing, someone suggested switching to PTP instead … Read more

Get Value of a Edit Text field

By using getText(): Button mButton; EditText mEdit; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mButton = (Button)findViewById(R.id.button); mEdit = (EditText)findViewById(R.id.edittext); mButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Log.v(“EditText”, mEdit.getText().toString()); } }); }

How to use LocalBroadcastManager?

I’ll answer this anyway. Just in case someone needs it. ReceiverActivity.java An activity that watches for notifications for the event named “custom-event-name”. @Override public void onCreate(Bundle savedInstanceState) { … // Register to receive messages. // We are registering an observer (mMessageReceiver) to receive Intents // with actions named “custom-event-name”. LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter(“custom-event-name”)); } // Our … Read more

Android emulator not able to access the internet

👉 1st try “Cold booting” the emulator as suggested here. 👉 If cold booting doesn’t work, try changing the DNS address of your network to 8.8.8.8 (Google’s DNS) or another of your preference: MacOSX: Open “System Preferences” Click on “Network” Select the network which your computer is connected and click on “Advanced” Select “DNS”, Select … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)