SpinnerActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_spinner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.bhaumik.programmingstudy.SpinnerActivity">
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_gravity="center_horizontal"
android:id="@+id/spinner" />
</LinearLayout>
Add This Resource String In Value String.xml File
<string-array name="str_language">
< item>Android< /item>
< item>Java< /item>
< item>Asp.Net< /item>
< item>C++< /item>
< item>Python< /item>
</string-array>
SpinnerActivity.java
package com.bhaumik.programmingstudy;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class ServicesActivity extends AppCompatActivity {
Button start,stop;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_services);
start = (Button) findViewById(R.id.btn_start);
stop = (Button) findViewById(R.id.btn_stop);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ServicesActivity.this,MyServices.class);
startService(intent);
}
});
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ServicesActivity.this,MyServices.class);
stopService(intent);
}
});
}
}
0 comments:
Post a Comment