A Pen by Farhan Faruque on CodePen.
This file contains 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>(); | |
//----------------------------------------------------------------------------- |
This file contains 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 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 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 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 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 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 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 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
if you make /var/www writeable by its group and add the user to the group, that user will not have to use sudo. Try this: | |
sudo adduser <username> www-data | |
sudo chown -R www-data:www-data /var/www | |
sudo chmod -R g+rw /var/www | |
The user should then be able to edit /var/www/ files without hassle. | |
The first line adds the user to the www-data group, the second line clears up any files with messed up ownership, and the third makes it so that all users who are members of the www-data group can read and write all files in /var/www. | |
If you are logged in as <username> you need to log out and log back in for the group membership to take effect. |
OlderNewer