Skip to content

Commit eb9d8c8

Browse files
committed
Uploaded Timetable App, Video App and Toast demo App
Video App -display Ready to born song Toast App - generate Toast on button press
1 parent fc977b4 commit eb9d8c8

File tree

3 files changed

+172
-0
lines changed

3 files changed

+172
-0
lines changed

timetables/MainActivity.java

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.lenovo.timetables;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
import android.util.Log;
6+
import android.widget.ArrayAdapter;
7+
import android.widget.ListView;
8+
import android.widget.SeekBar;
9+
10+
import java.util.ArrayList;
11+
12+
public class MainActivity extends AppCompatActivity {
13+
14+
ListView timesTableListView;
15+
16+
public void generateTimesTable(int timesTable)
17+
{
18+
19+
ArrayList<String> timesTableContent = new ArrayList<String>();
20+
for(int i=1;i<=20;i++)
21+
{
22+
timesTableContent.add(timesTable+" X "+i+" = "+Integer.toString(i*timesTable));
23+
}
24+
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,timesTableContent);
25+
timesTableListView.setAdapter(arrayAdapter);
26+
}
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
31+
32+
setContentView(R.layout.activity_main);
33+
34+
final SeekBar timesTableSeekbar = (SeekBar) findViewById(R.id.timestableSeekbar);
35+
timesTableListView = (ListView)findViewById(R.id.timesTablelistView);
36+
37+
timesTableSeekbar.setMax(20);
38+
timesTableSeekbar.setProgress(10);
39+
timesTableSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
40+
@Override
41+
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
42+
int min =1;
43+
int timesTable;
44+
45+
if(progress<min)
46+
{
47+
timesTable=min;
48+
timesTableSeekbar.setProgress(min);
49+
}
50+
else
51+
{
52+
timesTable=progress;
53+
}
54+
Log.i("Seekbar value:",Integer.toString(timesTable));
55+
generateTimesTable(timesTable);
56+
}
57+
58+
@Override
59+
public void onStartTrackingTouch(SeekBar seekBar) {
60+
61+
}
62+
63+
@Override
64+
public void onStopTrackingTouch(SeekBar seekBar) {
65+
66+
}
67+
});
68+
generateTimesTable(10);
69+
70+
}
71+
}

toastdemo/MainActivity.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.lenovo.toastdemo;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
import android.util.Log;
6+
import android.view.View;
7+
import android.widget.EditText;
8+
import android.widget.ImageView;
9+
import android.widget.Toast;
10+
11+
public class MainActivity extends AppCompatActivity {
12+
13+
public void sayHi(View view )
14+
{
15+
EditText name= (EditText) findViewById(R.id.NameId);
16+
ImageView image = (ImageView) findViewById(R.id.image);
17+
18+
Log.i("test","clicked");
19+
Toast.makeText(MainActivity.this,"Hit there, "+name.getText().toString(),Toast.LENGTH_SHORT).show();
20+
image.setImageResource(R.drawable.cat2);
21+
}
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_main);
26+
}
27+
}

video/MainActivity.java

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.lenovo.video;
2+
3+
import android.net.Uri;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.widget.MediaController;
7+
import android.widget.VideoView;
8+
9+
import com.google.android.gms.appindexing.Action;
10+
import com.google.android.gms.appindexing.AppIndex;
11+
import com.google.android.gms.appindexing.Thing;
12+
import com.google.android.gms.common.api.GoogleApiClient;
13+
14+
public class MainActivity extends AppCompatActivity {
15+
16+
/**
17+
* ATTENTION: This was auto-generated to implement the App Indexing API.
18+
* See https://g.co/AppIndexing/AndroidStudio for more information.
19+
*/
20+
private GoogleApiClient client;
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_main);
26+
27+
VideoView videoView = (VideoView)findViewById(R.id.videoView);
28+
videoView.setVideoPath("android.resource://"+getPackageName()+"/"+R.raw.demovideo);
29+
MediaController mediaController = new MediaController(this);
30+
mediaController.setAnchorView(videoView);
31+
videoView.setMediaController(mediaController);
32+
videoView.start();
33+
34+
// ATTENTION: This was auto-generated to implement the App Indexing API.
35+
// See https://g.co/AppIndexing/AndroidStudio for more information.
36+
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
37+
}
38+
39+
/**
40+
* ATTENTION: This was auto-generated to implement the App Indexing API.
41+
* See https://g.co/AppIndexing/AndroidStudio for more information.
42+
*/
43+
public Action getIndexApiAction() {
44+
Thing object = new Thing.Builder()
45+
.setName("Main Page") // TODO: Define a title for the content shown.
46+
// TODO: Make sure this auto-generated URL is correct.
47+
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
48+
.build();
49+
return new Action.Builder(Action.TYPE_VIEW)
50+
.setObject(object)
51+
.setActionStatus(Action.STATUS_TYPE_COMPLETED)
52+
.build();
53+
}
54+
55+
@Override
56+
public void onStart() {
57+
super.onStart();
58+
59+
// ATTENTION: This was auto-generated to implement the App Indexing API.
60+
// See https://g.co/AppIndexing/AndroidStudio for more information.
61+
client.connect();
62+
AppIndex.AppIndexApi.start(client, getIndexApiAction());
63+
}
64+
65+
@Override
66+
public void onStop() {
67+
super.onStop();
68+
69+
// ATTENTION: This was auto-generated to implement the App Indexing API.
70+
// See https://g.co/AppIndexing/AndroidStudio for more information.
71+
AppIndex.AppIndexApi.end(client, getIndexApiAction());
72+
client.disconnect();
73+
}
74+
}

0 commit comments

Comments
 (0)