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
// Get a Spinner and bind it to an ArrayAdapter that | |
// references a String array. | |
Spinner s1 = (Spinner) findViewById(R.id.spinner1); | |
ArrayAdapter adapter = ArrayAdapter.createFromResource( | |
this, R.array.colors, android.R.layout.simple_spinner_item); | |
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |
s1.setAdapter(adapter); | |
// Load a Spinner and bind it to a data query. | |
private static String[] PROJECTION = new String[] { |
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 myClickHandler(View view) { | |
... | |
ConnectivityManager connMgr = (ConnectivityManager) | |
getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); | |
if (networkInfo != null && networkInfo.isConnected()) { | |
// fetch data | |
} else { | |
// display error | |
} |
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
Button btnExample = (Button) findViewById(R.id.btnExample); | |
btnExample.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
// Do something here | |
} | |
}); |
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
EditText etValue = (EditText) findViewById(R.id.etValue); | |
etValue.addTextChangedListener(new TextWatcher() { | |
@Override | |
public void onTextChanged(CharSequence s, int start, int before, int count) { | |
// Fires right as the text is being changed (even supplies the range of text) | |
} | |
@Override | |
public void beforeTextChanged(CharSequence s, int start, int count, | |
int after) { |
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
@Override // this does not override a super class method. Whats up? | |
public void onClick(View view) { | |
switch (view.getId()) { | |
case R.id.taskButton: { | |
Intent intent = new Intent(this, TasksActivity.class); | |
startActivity(intent); | |
} | |
break; |
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
<LinearLayout 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:orientation="vertical" | |
android:paddingBottom="@dimen/activity_vertical_margin" | |
android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
tools:context=".MyActivity"> |
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
Phone Call | |
Permissions: | |
<uses-permission android:name="android.permission.CALL_PHONE" /> | |
Intent: | |
Intent callIntent = new Intent(Intent.ACTION_CALL); | |
callIntent.setData(Uri.parse("tel:0377778888")); | |
startActivity(callIntent); |
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
<!-- Load in Chrome Version 67.0.3396.87 (Official Build) (64-bit) on Mac OS 10.13.5 --> | |
<!-- Click on the white square in the button that is the checkbox. It will NOT toggle. Click on button toggles. --> | |
<div class="btn-group" data-toggle="buttons"> | |
<label class="btn btn-primary active"> | |
<input type="checkbox" checked autocomplete="off"> Checkbox 1 (pre-checked) | |
</label> | |
<label class="btn btn-primary"> | |
<input type="checkbox" autocomplete="off"> Checkbox 2 |
OlderNewer