小茶楼装修效果图大全:写下关于popwindow
来源:百度文库 编辑:中财网 时间:2024/05/07 05:29:50
主要是代码,参考了http://blog.csdn.net/Android_Tutor/archive/2010/05/10/5576533.aspx
popwindow.xml
C-sharp代码
- "1.0" encoding="utf-8"?>
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- android:id="@+id/textview"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="测试"
- />
main.xml
Java代码
- "1.0" encoding="utf-8"?>
"http://schemas.android.com/apk/res/android" - android:id="@+id/main"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- android:id="@+id/videoshow"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- />
Activity01.java
C-sharp代码
- package com.overflow.testvideo;
- import java.util.Timer;
- import java.util.TimerTask;
- import android.app.Activity;
- import android.content.Context;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.view.Gravity;
- import android.view.KeyEvent;
- import android.view.LayoutInflater;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.ViewGroup.LayoutParams;
- import android.widget.Button;
- import android.widget.MediaController;
- import android.widget.PopupWindow;
- import android.widget.TextView;
- import android.widget.VideoView;
- public class Activity01 extends Activity {
- VideoView vv = null;
- Button btn = null;
- TextView textview = null;
- /** Called when the activity is first created. */
- private Handler mHandler = new Handler(){
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case 1:
- showPopupWindow();
- break;
- }
- };
- };
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Timer timer = new Timer();
- timer.schedule(new initPopupWindow(), 100);
- //textview = (TextView) music_popunwindwow.
- //btn = (Button) this.findViewById(R.id.test);
- vv = (VideoView) this.findViewById(R.id.videoshow);
- vv.setVideoURI(Uri.parse("android.resource://com.overflow.testvideo/"+R.raw.underwater));
- vv.setMediaController(new MediaController(this));
- vv.start();
- vv.setOnTouchListener(new VideoView.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- // TODO Auto-generated method stub
- return true;
- }
- });
- }
- private class initPopupWindow extends TimerTask{
- @Override
- public void run() {
- Message message = new Message();
- message.what = 1;
- mHandler.sendMessage(message);
- }
- }
- public void showPopupWindow() {
- Context mContext = Activity01.this;
- LayoutInflater mLayoutInflater = (LayoutInflater) mContext
- .getSystemService(LAYOUT_INFLATER_SERVICE);
- View music_popunwindwow = mLayoutInflater.inflate(
- R.layout.popwindow, null);
- PopupWindow mPopupWindow = new PopupWindow(music_popunwindwow,
- LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
- mPopupWindow.showAtLocation(findViewById(R.id.main), Gravity.CENTER, 0, 0);
- btn = (Button) music_popunwindwow.findViewById(R.id.test);
- textview = (TextView) music_popunwindwow.findViewById(R.id.textview);
- btn.setOnClickListener(new Button.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- textview.setText("测试成功");
- }
- });
- }
- }
记得要dismiss(),否则返回会报错,难点在要触发popwindow上的事件,就必须是这个popwindow下来findviewbyid,否则就报错
本来这个东西的最初目的是写动态背景,但失败了,蛮多限制。贴上代码,以后可能需要。
请写下五首关于母爱的诗歌!!~~
谁能帮我写下关于"献给未来的回忆"?
跪求!:帮忙写下关于优秀班级的介绍!
关于假期计划的短文~ 高手门帮忙写下!~
写下经典台词!
急!!有谁可以帮我写下关于邓亚萍的英语作文!!
对偶题,关于我写上句,你对应的写下句
关于Dreamweaver 8的问题,麻烦写下详细步骤。本人在线等!
有没有关于学习电脑知识的好网站啊, 写下网址.
高手哥哥们能帮我写下关于感恩的演讲稿不?小第
大家能帮我写下关于"看"的词语吗,帮帮忙拉
谁知道关于写罗宾汉的英文诗,请写下诗名及内容,英文的。谢谢
关于合作的作文 如果有 请写下 我会感谢你的
作业里要写的句子,关于水浒的,帮忙写下吧~*_*<有格式>
谁帮我写下关于HAPPY的QQ个性签名和个人资料???
谁知道关于写彼得潘的英文诗,请写下诗名及内容,英文的。谢谢
写下经典的句子.
写下经典的“班训”
帮忙写下句
写下你的故事
谁写下了“难得糊涂”
先生曾写下“难得糊涂”
好心人帮忙写下答案!
帮忙仿写下篇文章