Demo entry 6359881

Java

   

Submitted by harry on Apr 30, 2017 at 11:47
Language: Java. Code size: 2.9 kB.

package com.childedu.main;

import org.apache.cordova.CordovaActivity;

import com.childedu.game.GameIndex;
import com.childedu.login.LoginAct;
import com.childedu.pinyin.Pinyin;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends CordovaActivity
{
	private Button ImgBtn1,ImgBtn2,ImgBtn3,ImgBtn4,bgmusic,login;
	private de.hdodenhof.circleimageview.CircleImageView userPic;
	Boolean f =false;
	BackgroundMusic b = new BackgroundMusic(MainActivity.this);
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        userPic = (de.hdodenhof.circleimageview.CircleImageView)findViewById(R.id.circleImageView1);
        ImgBtn1 = (Button)findViewById(R.id.imageButton1);
        ImgBtn2 = (Button)findViewById(R.id.imageButton2);
        ImgBtn3 = (Button)findViewById(R.id.imageButton3);
        ImgBtn4 = (Button)findViewById(R.id.imageButton4);
        bgmusic = (Button)findViewById(R.id.bgmusic);
        login = (Button)findViewById(R.id.login);
        ImgBtn1.setOnClickListener(ImgbtnLis);
        ImgBtn2.setOnClickListener(ImgbtnLis);
        ImgBtn3.setOnClickListener(ImgbtnLis);
        ImgBtn4.setOnClickListener(ImgbtnLis);
        bgmusic.setOnClickListener(ImgbtnLis);
        login.setOnClickListener(ImgbtnLis);
    }
    private View.OnClickListener ImgbtnLis = new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.imageButton1:
				Intent pinyinit = new Intent();
				pinyinit.setClass(MainActivity.this, Pinyin.class);
		    	startActivity(pinyinit);
				break;
			case R.id.imageButton2:
				Intent hanziit = new Intent();
				hanziit.setClass(MainActivity.this, Hanzi.class);
		    	startActivity(hanziit);			
				break;
			case R.id.imageButton3:
				Intent videoit = new Intent();
				videoit.setClass(MainActivity.this, PlayVoice.class);
		    	startActivity(videoit);
				break;
			case R.id.imageButton4:
				Intent gameIndex = new Intent();
		    	gameIndex.setClass(MainActivity.this, GameIndex.class);
		    	startActivity(gameIndex);
				break;
			case R.id.circleImageView1:
				
				break;
			case R.id.bgmusic:
				b.playBackgroundMusic("sleep.mp3", true);
				if (f==false) {
					f = true;
					bgmusic.setBackgroundResource(R.drawable.shengyinf);
				}else {
					f = false;
					b.end();
					bgmusic.setBackgroundResource(R.drawable.shengyin);
				}
				break;
			case R.id.login:
				Intent loginIndex = new Intent();
				loginIndex.setClass(MainActivity.this, LoginAct.class);
		    	startActivity(loginIndex);
				break;
			default:
				break;
			}
			
		}
	};
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).