In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use Start Activity,Stop Activity and Suspend Activity", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use Start Activity,Stop Activity and Suspend Activity" article.
Start Activity;Stop Activity and Suspend Activity are used to play music, stop music and pause playback, respectively.
Package mth.android
Import android.app.Activity
Import android.media.MediaPlayer
Import android.os.Bundle
Import android.view.View
Import android.widget.Button
Import android.widget.TextView
Public class AndroidActivity extends Activity implements View.OnClickListener {
/ / Define a media player
Private MediaPlayer mediaPlayer = null
Private int curPos = 0
/ * Called when the activity is first created. , /
@ Override
Public void onCreate (Bundle savedInstanceState) {
Super.onCreate (savedInstanceState)
SetContentView (R.layout.main)
/ / final View textDisplayer = this.findViewById (R.id.displayText)
/ / final TextView textDisplayer = (TextView) this.findViewById (R.id.displayText)
Button startActivityButton = (Button) this.findViewById (R.id.startAndroidActivity)
StartActivityButton.setOnClickListener (this)
Button stopActivityButton = (Button) this.findViewById (R.id.stopAndroidActivity)
StopActivityButton.setOnClickListener (this)
Button suspendActivityButton = (Button) this.findViewById (R.id.suspendAndroidActivity)
SuspendActivityButton.setOnClickListener (this)
/ *
Button startActivityButton = (Button) this.findViewById (R.id.startAndroidActivity)
StartActivityButton.setOnClickListener (new OnClickListener () {
Public void onClick (View v) {
/ / TODO Auto-generated method stub
Display (textDisplayer)
}
});
, /
/ *
View startActivityButton = this.findViewById (R.id.startAndroidActivity)
StartActivityButton.setOnClickListener (new View.OnClickListener () {
Public void onClick (View v) {
/ / TODO Auto-generated method stub
TextDisplayer.setText ("Hello World")
TextDisplayer.setBackgroundColor (0xFFFFFFFF)
}
}
);
, /
/ *
TextView text = new TextView (this)
Text.setText ("Hello World")
SetContentView (text)
, /
}
Public void display (TextView tv)
{
Tv.setText ("Hello world")
Tv.setBackgroundColor (0xFFFFFF00)
}
Public void onClick (View v) {
/ / int curPos = 0
Switch (v.getId ())
{
Case R.id.startAndroidActivity:
/ / TODO Auto-generated method stub
Final TextView textDisplayer = (TextView) this.findViewById (R.id.displayText)
TextDisplayer.setText ("Hello world")
TextDisplayer.setBackgroundColor (BIND_AUTO_CREATE)
/ / Start media player
MediaPlayer = MediaPlayer.create (this, R.raw.just_one_last_dance)
MediaPlayer.seekTo (0)
MediaPlayer.start ()
Break
Case R.id.stopAndroidActivity:
MediaPlayer.stop ()
Break
Case R.id.suspendAndroidActivity:
If (true = = mediaPlayer.isPlaying ())
{
CurPos = mediaPlayer.getCurrentPosition ()
MediaPlayer.pause ()
}
Else
{
MediaPlayer.seekTo (curPos)
MediaPlayer.start ()
}
Break
Default:
Break
}
}
}
The above is about the content of this article on "how to use Start Activity,Stop Activity and Suspend Activity". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.