学期末老师让做一个安卓的小项目所以我就做了这个记事本的小app
在这边记录下源代码,方便以后查看
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
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"
tools:context="com.example.guoqing.diary.MainActivity">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginStart="57dp"
android:layout_marginTop="74dp"
android:id="@+id/editText"
android:hint="ID NUMBER" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:layout_below="@+id/editText"
android:layout_alignEnd="@+id/editText"
android:layout_marginTop="28dp"
android:id="@+id/editText2"
android:hint="PASSWORD" />
<Button
android:text="LOGIN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_alignStart="@+id/editText2"
android:layout_marginTop="57dp"
android:id="@+id/button" />
<Button
android:text="REGISTER"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button"
android:layout_alignEnd="@+id/editText2"
android:id="@+id/button2" />
</RelativeLayout>
main.java
package com.example.guoqing.diary;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button login;
Button register;
EditText id;
EditText password;
private static final String DATABASE_NAME = "Mydb";
private static final String TABLE_NAME = "Mytb";
private SQLiteDatabase sqlDB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sqlDB = openOrCreateDatabase(DATABASE_NAME,SQLiteDatabase.CREATE_IF_NECESSARY,null);
// Toast.makeText(getApplicationContext(),"数据库创建成功",Toast.LENGTH_SHORT).show();
try {
sqlDB.execSQL("create table " + TABLE_NAME + " (id integer primary key ,password text)");
}catch(Exception e){
// Toast.makeText(getApplicationContext(),"表格已经存在",Toast.LENGTH_SHORT).show();
}
login = (Button)findViewById(R.id.button);
register = (Button)findViewById(R.id.button2);
id = (EditText)findViewById(R.id.editText);
password = (EditText)findViewById(R.id.editText2);
login.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Cursor c = sqlDB.query(TABLE_NAME,null,"id=?",new String[]{id.getText().toString()},null,null,null);
if(c.moveToNext()){
String strValue= c.getString(1);
if(password.getText().toString().equals(strValue)){
Intent i = new Intent(getApplicationContext(),home.class);
startActivity(i);
}
else
{
Toast.makeText(getApplicationContext(),"error",Toast.LENGTH_SHORT).show();
}
}
}
});
register.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this, com.example.guoqing.diary.register.class);
startActivity(i);
}
});
}
}
regitter.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_register"
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"
tools:context="com.example.guoqing.diary.register">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:layout_below="@+id/editText3"
android:layout_alignEnd="@+id/editText3"
android:layout_marginTop="26dp"
android:id="@+id/editText4"
android:hint="PASSWORD" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:layout_marginTop="29dp"
android:id="@+id/editText5"
android:hint="REPEAT"
android:layout_below="@+id/editText4"
android:layout_alignStart="@+id/editText4" />
<Button
android:text="REGISTER"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText5"
android:layout_alignStart="@+id/editText5"
android:layout_marginTop="28dp"
android:id="@+id/button3" />
<Button
android:text="LOGIN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button3"
android:layout_alignEnd="@+id/editText5"
android:id="@+id/button4" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:layout_marginTop="76dp"
android:id="@+id/editText3"
android:hint="ID NUMBER"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
register.java
package com.example.guoqing.diary;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class register extends AppCompatActivity {
EditText id;
EditText password;
EditText repeat;
Button register;
Button login;
private static final String DATABASE_NAME = "Mydb";
private static final String TABLE_NAME = "Mytb";
private SQLiteDatabase sqlDB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
id = (EditText)findViewById(R.id.editText3);
password = (EditText)findViewById(R.id.editText4);
repeat = (EditText)findViewById(R.id.editText5);
register = (Button)findViewById(R.id.button3);
login = (Button)findViewById(R.id.button4);
sqlDB = openOrCreateDatabase(DATABASE_NAME, SQLiteDatabase.CREATE_IF_NECESSARY,null);
//Toast.makeText(getApplicationContext(),"数据库打开成功",Toast.LENGTH_SHORT).show();
try {
sqlDB.execSQL("create table " + TABLE_NAME + " (id integer primary key ,password text)");
}catch(Exception e){
// Toast.makeText(getApplicationContext(),"表格已经存在",Toast.LENGTH_SHORT).show();
}
register.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
if( !id.getText().toString().equals("") && !password.getText().toString().equals("") && !repeat.getText().toString().equals("")) {
if(repeat.getText().toString().equals(password.getText().toString())){
ContentValues cv = new ContentValues();
cv.put("id", id.getText().toString());
cv.put("password", password.getText().toString());
sqlDB.insertOrThrow(TABLE_NAME,null,cv);
Toast.makeText(getApplicationContext(),"register successful,you can login now!",Toast.LENGTH_SHORT).show();
}
else {
//Toast.makeText(getApplicationContext(),id.getText().toString() +" " + password.getText().toString() +" "+ repeat.getText().toString(),Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),"check your password and repeat ",Toast.LENGTH_SHORT).show();
}
}else{
Toast.makeText(getApplicationContext(),"can not be empty",Toast.LENGTH_SHORT).show();
// Toast.makeText(getApplicationContext(),id.getText().toString() +" " + password.getText().toString() +" "+ repeat.getText().toString(),Toast.LENGTH_SHORT).show();
}
}
});
login.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),MainActivity.class);
startActivity(i);
}
});
}
}
home.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_home"
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"
tools:context="com.example.guoqing.diary.home"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/ic_input_add"
android:id="@+id/imageButton"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true" />
<ListView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_above="@+id/imageButton"
android:id="@+id/listview" />
</RelativeLayout>
listviewlayout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:textColor="#1D1D1C"
android:textSize="20sp"/>
<TextView
android:id="@+id/time1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:textColor="#B4B4B9"
android:textSize="14sp"/>
</LinearLayout>
</LinearLayout>
home.java
package com.example.guoqing.diary;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CursorAdapter;
import android.widget.ImageButton;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.Toast;
import android.content.DialogInterface;
import java.util.ArrayList;
import java.util.List;
public class home extends AppCompatActivity {
ImageButton add;
public ListView listView;
private static final String DATABASE_NAME = "Mydb";
private static final String TABLE_NAME = "diary1";
private SQLiteDatabase sqlDB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
sqlDB = openOrCreateDatabase(DATABASE_NAME, SQLiteDatabase.CREATE_IF_NECESSARY,null);
//Toast.makeText(getApplicationContext(),"数据库打开成功",Toast.LENGTH_SHORT).show();
try {
sqlDB.execSQL("create table " + TABLE_NAME + " (_id text,title text ,weather text ,time text, context text)");
}catch(Exception e){
// Toast.makeText(getApplicationContext(),"表格已经存在",Toast.LENGTH_SHORT).show();
}
final Cursor c = sqlDB.query(TABLE_NAME, null, null, null, null, null, null);
final SimpleCursorAdapter listAdapter = new SimpleCursorAdapter(this,
R.layout.listviewlayout,
c,
new String[]{"title", "time"},
new int[]{R.id.title1, R.id.time1},
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
listView = (ListView) findViewById(R.id.listview);
listView.setAdapter(listAdapter);
listView.invalidateViews();
//点击进入详情页面
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Toast.makeText(getApplicationContext(),"aaaa",Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(),details.class);
i.putExtra("title",c.getString(1));
i.putExtra("weather",c.getString(2));
i.putExtra("time",c.getString(3));
i.putExtra("context",c.getString(4));
startActivity(i);
}
});
//长按弹出是否删除的对话框
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, final long id) {
//Toast.makeText(getApplicationContext(),"Longpress",Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(home.this);
builder.setTitle("Prompt");
builder.setMessage("Do you want to delete?");
builder.setNegativeButton("Cancel",new DialogInterface.OnClickListener(){
public void onClick (DialogInterface arg0,int arg1)
{
// Toast.makeText(getApplicationContext(),"cancel",Toast.LENGTH_SHORT).show();
}
});
builder.setPositiveButton("OK",new DialogInterface.OnClickListener(){
public void onClick(DialogInterface arg0,int arg1)
{
//Toast.makeText(getApplicationContext(),"ok",Toast.LENGTH_SHORT).show();
c.moveToPosition(position);
String title_name = c.getString(1);
sqlDB.delete(TABLE_NAME,"title=?",new String[]{title_name});
Intent i=new Intent(getApplicationContext(),home.class);
startActivity(i);
}
});
builder.show();
return true;
}
});
add = (ImageButton) findViewById(R.id.imageButton);
add.setOnClickListener(new ImageButton.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),write.class);
startActivity(i);
}
});
}
}
write.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_write"
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"
tools:context="com.example.guoqing.diary.write">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/editText6"
android:hint="Title"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editText6"
android:layout_marginTop="14dp"
android:id="@+id/spinner" />
<TextView
android:text="Time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:id="@+id/textView"
android:layout_below="@+id/spinner"
android:layout_alignParentStart="true"
android:layout_marginStart="34dp" />
<TextView
android:text="weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView"
android:layout_alignEnd="@+id/editText6"
android:id="@+id/textView2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/editText7"
android:layout_marginTop="26dp"
android:layout_below="@+id/textView2"
android:layout_alignEnd="@+id/button5"
android:layout_alignParentStart="true" />
<Button
android:text="SAVE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="18dp"
android:id="@+id/button5"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
<Button
android:text="BACK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/button6"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
write.java
package com.example.guoqing.diary;
import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class write extends AppCompatActivity {
EditText title;
EditText context;
Spinner weather;
Button save;
TextView date;
TextView wea;
Button back;
private static final String DATABASE_NAME = "Mydb";
private static final String TABLE_NAME = "diary1";
private SQLiteDatabase sqlDB;
private List<String> list = new ArrayList<String>();
private ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_write);
sqlDB = openOrCreateDatabase(DATABASE_NAME, SQLiteDatabase.CREATE_IF_NECESSARY,null);
//Toast.makeText(getApplicationContext(),"数据库打开成功",Toast.LENGTH_SHORT).show();
try {
sqlDB.execSQL("create table " + TABLE_NAME + " (_id text ,title text ,weather text ,time text, context text)");
}catch(Exception e){
// Toast.makeText(getApplicationContext(),"表格已经存在",Toast.LENGTH_SHORT).show();
}
list.add("Sunny");
list.add("Cloudy");
list.add("Rain");
list.add("Snow");
list.add("Wind");
wea = (TextView)findViewById(R.id.textView2);
date=(TextView)findViewById(R.id.textView);
title = (EditText)findViewById(R.id.editText6);
context=(EditText)findViewById(R.id.editText7);
weather = (Spinner)findViewById(R.id.spinner);
save = (Button)findViewById(R.id.button5);
adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
weather.setAdapter(adapter);
//get Time
long time=System.currentTimeMillis();
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1=new Date(time);
String t=format.format(d1);
date.setText(t);
// Toast.makeText(getApplicationContext(),t,Toast.LENGTH_SHORT).show();
weather.setOnItemSelectedListener(new Spinner.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
wea.setText(adapter.getItem(arg2));
arg0.setVisibility(View.VISIBLE);
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
//title.getText()
//date.getText()
//context.getText()
//weather.getText()
back=(Button)findViewById(R.id.button6);
back.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),home.class);
startActivity(i);
}
});
save.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
if(!title.getText().toString().equals("") && !context.getText().toString().equals("")) {
String biaoti = title.getText().toString();
String riqi = date.getText().toString();
String tianqi = wea.getText().toString();
String neirong = context.getText().toString();
//title text ,weather text ,time text, context text
ContentValues cv = new ContentValues();
cv.put("title",biaoti);
cv.put("weather",tianqi);
cv.put("time",riqi);
cv.put("context",neirong);
sqlDB.insertOrThrow(TABLE_NAME,null,cv);
//Toast.makeText(getApplicationContext(),"save successful,you can go back now!",Toast.LENGTH_SHORT).show();
Intent i= new Intent(getApplicationContext(),home.class);
startActivity(i);
}else{
Toast.makeText(getApplicationContext(),"title or context can not empty",Toast.LENGTH_SHORT).show();
}
}
});
}
}
Detail.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_details"
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"
tools:context="com.example.guoqing.diary.details">
<TextView
android:text="Title:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="16dp"
android:id="@+id/textView3" />
<TextView
android:text="Time:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView3"
android:layout_alignParentStart="true"
android:layout_marginTop="18dp"
android:id="@+id/textView5" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView5"
android:layout_alignEnd="@+id/textView4"
android:id="@+id/textView6" />
<TextView
android:text="weather:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView5"
android:layout_alignParentStart="true"
android:layout_marginTop="26dp"
android:id="@+id/textView7" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/textView7"
android:layout_alignStart="@+id/textView6"
android:id="@+id/textView8" />
<TextView
android:text="Context:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView7"
android:layout_alignParentStart="true"
android:layout_marginTop="38dp"
android:id="@+id/textView9" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_above="@+id/textView5"
android:layout_alignParentEnd="true"
android:layout_marginEnd="65dp" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="41dp"
android:id="@+id/textView10"
android:layout_below="@+id/textView9"
android:layout_alignParentStart="true" />
<Button
android:text="BACK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="@+id/button7"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
Detail.java
package com.example.guoqing.diary;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class details extends AppCompatActivity {
TextView title;
TextView time;
TextView weather;
TextView context;
Button back;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
title = (TextView)findViewById(R.id.textView4);
time = (TextView)findViewById(R.id.textView6);
weather = (TextView)findViewById(R.id.textView8);
context = (TextView)findViewById(R.id.textView10);
Intent i = getIntent();
String titlec = i.getStringExtra("title");
String timec = i.getStringExtra("time");
String weatherc = i.getStringExtra("weather");
String contextc = i.getStringExtra("context");
title.setText(titlec);
time.setText(timec);
weather.setText(weatherc);
context.setText(contextc);
back=(Button)findViewById(R.id.button7);
back.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),home.class);
startActivity(i);
}
});
}
}
下面是运行图片