This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void setCurrentWithClearTop(Class<?> klass,Bundle b) | |
| { | |
| Intent intentToBeNewRoot = new Intent(this, klass); | |
| ComponentName cn = intentToBeNewRoot.getComponent(); | |
| Intent mainIntent = IntentCompat.makeRestartActivityTask(cn); | |
| startActivity(mainIntent); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void hideSoftKeyboard() | |
| { | |
| InputMethodManager inputManager = (InputMethodManager) | |
| getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); | |
| View v = getActivity().getCurrentFocus(); | |
| if(v == null) | |
| return; | |
| inputManager.hideSoftInputFromWindow(v.getWindowToken(), | |
| InputMethodManager.HIDE_NOT_ALWAYS); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void setCustomActionbar() | |
| { | |
| actionBar.setLogo(null); // forgot why this one but it helped | |
| View homeIcon = findViewById(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ? | |
| android.R.id.home : android.support.v7.appcompat.R.id.home); | |
| ((View) homeIcon.getParent()).setVisibility(View.GONE); | |
| ((View) homeIcon).setVisibility(View.GONE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Step 1: Remove lock file. | |
| sudo rm /var/lib/mongodb/mongod.lock | |
| Step 2: Repair mongodb. | |
| mongod --repair | |
| Step 3: start mongodb. | |
| sudo start mongodb | |
| or | |
| sudo service mongodb start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Even if you haven't tracked the files so far, git seems to be able to "know" about them even after you add them to .gitignore. | |
| A quick fix that I've used was to run the following commands from the top folder of your git repo: | |
| (edited) | |
| git rm -r --cached . | |
| Followed by: | |
| git add . | |
| and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.sel.code; | |
| import java.util.Set; | |
| import android.app.Activity; | |
| import android.bluetooth.BluetoothAdapter; | |
| import android.bluetooth.BluetoothDevice; | |
| import android.content.Intent; | |
| import android.os.Bundle; | |
| import android.util.Log; | |
| import android.view.View; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OpenPdf extends Activity { | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.main); | |
| Button button = (Button) findViewById(R.id.OpenPdfButton); | |
| button.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View v) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| After figuring out which ViewPager methods are called by ViewPager and which are for other purposes, I came up with a solution. I present it here since I see a lot of people have struggled with this and I didn't see any other relevant answers. | |
| First, here's my adapter; hopefully comments within the code are sufficient: | |
| class MainPagerAdapter extends PagerAdapter | |
| { | |
| // This holds all the currently displayable views, in order from left to right. | |
| private ArrayList<View> views = new ArrayList<View>(); | |
| //----------------------------------------------------------------------------- |
NewerOlder