[MainActivity]
package com.example.videopoem;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void ShowPoem(View view){
int id = view.getId();
LinearLayout layout = (LinearLayout) findViewById(id);
String tag = (String) layout.getTag();
Intent it = new Intent(this, ShowPoem.class);
it.putExtra("it_tag", tag);
startActivity(it);
}
public void ShowTrip(View view){
int id = view.getId();
ImageView imageView = (ImageView) findViewById(id);
String tag = (String) imageView.getTag();
Intent it = new Intent(this, ShowTrip.class);
it.putExtra("it_tag", tag);
startActivity(it);
}
public void ShowVideo(View view){
int id = view.getId();
LinearLayout layout = (LinearLayout) findViewById(id);
String tag = (String)layout.getTag();
Intent it = new Intent(this, ShowVideo.class);
it.putExtra("it_tag", tag);
startActivity(it);
}
public void goBack(View view) {
}
}
[Showpoem]
package com.example.videopoem;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class ShowPoem extends AppCompatActivity {
LinearLayout layout;
TextView ptitle, author, body;
ImageView pimg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.poem);
layout = (LinearLayout) findViewById(R.id.poemlayout);
ptitle = (TextView) findViewById(R.id.ptitle);
author = (TextView) findViewById(R.id.author);
body = (TextView) findViewById(R.id.body);
pimg=(ImageView) findViewById(R.id.pimg);
Resources res = getResources();
Intent it = getIntent();
String tag = it.getStringExtra("it_tag");
int image_id =
res.getIdentifier("pimage"+tag, "string", getPackageName());
String image_str = res.getString(image_id);
int id_drawable =
res.getIdentifier(image_str, "drawable", getPackageName());
Drawable drawable = getDrawable(id_drawable);
pimg.setBackground(drawable);
int title_id = res.getIdentifier("ptitle" + tag, "string", getPackageName());
String title_str = res.getString(title_id);
ptitle.setText(title_str);
setTitle(title_str);
int author_id = res.getIdentifier("author" + tag, "string", getPackageName());
String author_str = res.getString(author_id);
author.setText(author_str);
int body_id = res.getIdentifier("body" + tag, "string", getPackageName());
String body_str = res.getString(body_id);
body.setText(body_str);
} // onCreaet
public void goBack(View view){
finish();
}// goBack
}
[ShowTrip]
package com.example.videopoem;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class ShowTrip extends AppCompatActivity {
LinearLayout layout;
TextView title, body;
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.trip);
layout = (LinearLayout) findViewById(R.id.poemlayout);
title = (TextView) findViewById(R.id.title);
body = (TextView) findViewById(R.id.body);
img=(ImageView) findViewById(R.id.img);
Resources res = getResources();
Intent it = getIntent();
String tag = it.getStringExtra("it_tag");
int image_id =
res.getIdentifier("tripimage"+tag, "string", getPackageName());
String image_str = res.getString(image_id);
int id_drawable =
res.getIdentifier(image_str, "drawable", getPackageName());
Drawable drawable = getDrawable(id_drawable);
img.setBackground(drawable);
int title_id = res.getIdentifier("triptitle" + tag, "string", getPackageName());
String title_str = res.getString(title_id);
title.setText(title_str);
setTitle(title_str);
int body_id = res.getIdentifier("tripbody" + tag, "string", getPackageName());
String body_str = res.getString(body_id);
body.setText(body_str);
} // onCreaet
public void goBack(View view){
finish();
}// goBack
}
[ShowVideo]
package com.example.videopoem;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.appcompat.app.AppCompatActivity;
public class ShowVideo extends AppCompatActivity {
LinearLayout layout;
TextView title;
VideoView video;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.playvideo);
layout = (LinearLayout) findViewById(R.id.videolayout);
title = (TextView) findViewById(R.id.title);
video = (VideoView) findViewById(R.id.video);
Resources res = getResources();
Intent it = getIntent();
String tag = it.getStringExtra("it_tag");
int title_id = res.getIdentifier("title"+tag, "string", getPackageName());
String title_str = res.getString(title_id);
title.setText(title_str);
int video_id =
res.getIdentifier("video"+tag, "string", getPackageName());
String video_str = res.getString(video_id);
int raw_id =
res.getIdentifier(video_str, "raw", getPackageName());
Uri uri = Uri.parse("android.resource://com.example.videopoem/"+raw_id);
video.setVideoURI(uri);
video.setVisibility(View.VISIBLE);
video.start();
}
public void goBack(View view){
finish();
}// goBack
}
[Manifest]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.videopoem">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Videopoem"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ShowVideo"></activity>
<activity android:name=".ShowPoem"></activity>
<activity android:name=".ShowTrip"></activity>
</application>
</manifest>
'학교 > Android' 카테고리의 다른 글
DBpersonnelRegistApp (AndroidManifest, DBManager, MainActivity, PersonnelDetail, PersonnelInfo, PersonnelList, PersonnelReg) (1) | 2024.06.08 |
---|---|
ShowVideo.java (videoListApp) (0) | 2024.04.17 |
MainActivity.java (videoListApp) (0) | 2024.04.17 |
ShowPoem.java (poemApp01) (0) | 2024.04.17 |
MainActivity.java (poemApp01) (0) | 2024.04.17 |