package com.nyurals.school;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
public class SettingsActitivity extends Activity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_settings );
ActionBar actionBar = getActionBar();
actionBar.show();
actionBar.setTitle("SETTINGS");
int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView textView = (TextView)findViewById(titleId);
// textView.setText("ANNOUNCEMENTS");
textView.setTextColor(android.graphics.Color.BLUE);
actionBar.setDisplayHomeAsUpEnabled(true);
init();
super.onCreate(savedInstanceState);
}
private void init() {
//textParentName = (TextView) findViewById(R.)
String[] items = { "Nursery", "KG-I", "KG-II", "I", "II",
"III", "IV", "V" };
Spinner spinnerForClass = (Spinner) findViewById(R.id.spinnerClass);
// spinnerForClass.setOnItemSelectedListener(this);
ArrayAdapter<String> spinnerClass = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,items);
spinnerForClass.setAdapter(spinnerClass);
}
public void addChildren(View view) {
Toast.makeText(SettingsActitivity.this, "Clicked on Add", Toast.LENGTH_SHORT).show();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.menu_settings, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.item_save:
Toast.makeText(SettingsActitivity.this, "Details saved.. Thank You!!", Toast.LENGTH_SHORT).show();
return true;
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
default:
return false;
}
}
}
在上面添加子方法的代码中,我应该写什么来再次添加子项????即如何添加编辑文本和微调器,就像它已经存在于 XML 中一样......请提出任何解决方案......