Page A
*** currently under construction ***
[java] package de.clarisweb.android.listview; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ListView myListView = findViewById((R.id.myListView)); final ArrayList myFamily = new ArrayList(); myFamily.add("P1"); myFamily.add("P2"); myFamily.add("P3"); myFamily.add("P4"); myFamily.add("P5"); final ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, myFamily); myListView.setAdapter(arrayAdapter); myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long
[java] package de.clarisweb.android.downloadwebcontent; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; public class MainActivity extends AppCompatActivity { public class DownloadTask extends AsyncTask { @Override protected String doInBackground(String… strings) { Log.i("URL", strings[0]); return "done !"; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); DownloadTask task = new DownloadTask(); String result=null; try { result =
Android: Timer
[java] @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new CountDownTimer(10000, 100) { public void onTick(long millisecondsUntilDone) { Log.i("Seconds Left!", String.valueOf(millisecondsUntilDone / 1000)); Toast.makeText(MainActivity.this, "" + String.valueOf(millisecondsUntilDone / 1000), Toast.LENGTH_SHORT).show(); } public void onFinish() { Log.i("We’re done!", "No more countdown"); } }.start();</pre> [/java]
Share this: