2013年11月28日 星期四

webview設定

WebSettings websettings=wv1.getSettings();
websettings.setJavaScriptEnabled(true);
websettings.setBuiltInZoomControls(true);
wv1.setWebViewClient(new WebViewClient());
wv1.setWebChromeClient(new WebChromeClient());
wv1.setBackgroundColor(0);//設定背景顏色為透明


http://blog.chinaunix.net/u1/38994/showart_1680699.html

# mount -o bind /root/test /sdcard && chmod 777 /sdcard
setprop EXTERNAL_STORAGE_STATE mounted
# am broadcast -a android.intent.action.MEDIA_MOUNTED --ez read-only false -d file:///sdcard

2013年11月27日 星期三

畫面觸控事件

package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.*;


public class Viewanimator3 extends Activity
{
private ViewAnimator va1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.viewanimator3);

va1 = (ViewAnimator)findViewById(R.id.viewAnimator1);
Animation inAnim = new AlphaAnimation(0,1);
inAnim.setDuration(2000);
Animation outAnim = new AlphaAnimation(1,0);
outAnim.setDuration(2000);
va1.setInAnimation(inAnim);
va1.setOutAnimation(outAnim);

}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction()==MotionEvent.ACTION_UP)
{
va1.showNext();
}
return true;
}


}
____________________
<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ViewAnimator
            android:id="@+id/viewAnimator1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="0.6" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="程式設計" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="美工設計" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="資料庫設計" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="手機程式設計" />

            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="網頁設計" />

        </ViewAnimator>

    </LinearLayout>

</LinearLayout>


視圖動畫元件ViewAnimator

1.無限制放元件量
2資源
          文字 TextView
         圖片ImageView
         版面LinearLayout
3..package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.*;


public class Viewanimator2 extends Activity
{
private ViewAnimator va1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.viewanimator2);

va1 = (ViewAnimator)findViewById(R.id.viewAnimator1);
Animation inAnim = new AlphaAnimation(0,1);
inAnim.setDuration(2000);
Animation outAnim = new AlphaAnimation(1,0);
outAnim.setDuration(2000);
va1.setInAnimation(inAnim);
va1.setOutAnimation(outAnim);

Button bt1=(Button)findViewById(R.id.button1);
bt1.setOnClickListener(myanilistener9);


}
Button.OnClickListener myanilistener9 = new Button.OnClickListener()
{

@Override
public void onClick(View v) {
va1.showNext();

}

};
}
________________________________
<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ViewAnimator
            android:id="@+id/viewAnimator1"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="0.6" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="程式設計" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="美工設計" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="資料庫設計" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="手機程式設計" />

            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="網頁設計" />

        </ViewAnimator>

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.4"
            android:text="下一資源" />

    </LinearLayout>

</LinearLayout>
_______________________________________________

2013年11月22日 星期五

1122課程

整數陣列搭配ImageSwitcher:
1.int[] a={R.drawable.x1,R.drawable.x2,R.drawable.x3,R.drawable.x4};

2.版面安排
<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="產品展示"
            android:textSize="20sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="364dp" >

        <ImageSwitcher
            android:id="@+id/imageSwitcher1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="@drawable/a13" />

        </ImageSwitcher>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="上一張" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="下一張" />

    </LinearLayout>

</LinearLayout>



3.public class ImageArray1 extends Activity implements ViewFactory
 {
         is1.setFactory(this);
.        is1.setImageResource(img[0]);
.
.
      public View  makeView()
      {
              ImageView  iv=new ImageView(this);
              iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
             iv.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,
                                                                                     LayoutParams.MATCH_PARENT));
            return iv;
       }
 }


--------------------
package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.*;
import android.widget.TableLayout.LayoutParams;
import android.widget.ViewSwitcher.ViewFactory;


public class Imageswitch2 extends Activity implements ViewFactory
{
private int[] img={R.drawable.a10,R.drawable.a11,R.drawable.a12,R.drawable.a13};
private ImageSwitcher is1=null;
private int po=0;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.imageswitch2);
is1=(ImageSwitcher)findViewById(R.id.imageSwitcher1);
is1.setFactory(this);
is1.setInAnimation(AnimationUtils.loadAnimation(this,android.R.anim.fade_in));
is1.setInAnimation(AnimationUtils.loadAnimation(this,android.R.anim.fade_out));
is1.setImageResource(img[0]);
Button bt1 = (Button)findViewById(R.id.button1);
Button bt2 = (Button)findViewById(R.id.button2);
bt1.setOnClickListener(mybtlistener5);
bt2.setOnClickListener(mybtlistener5);
}
Button.OnClickListener mybtlistener5 = new Button.OnClickListener()
{

@Override
public void onClick(View v) {
switch (v.getId())
{
case R.id.button1:
{
po--;
if (po<0)
{
po=img.length-1;
}
is1.setImageResource(img[po]);
break;
}
case R.id.button2:
{
po++;
if (po>img.length-1)
{
po=0;
}
is1.setImageResource(img[po]);
break;
}
}
}
};
@Override
public View makeView() {
// TODO Auto-generated method stub
ImageView iv =new ImageView(this);//動態建立ImageView
iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
iv.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,android.view.ViewGroup.LayoutParams.MATCH_PARENT));
return iv;
}
}
---------------------

<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="產品展示"
            android:textSize="20sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="364dp" >

        <ImageSwitcher
            android:id="@+id/imageSwitcher1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

        </ImageSwitcher>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="上一張" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="下一張" />

    </LinearLayout>

</LinearLayout>


-----------
package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.TextView;

public class Animation1 extends Activity
{
private TextView tv=null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.animation1);

tv=(TextView)findViewById(R.id.textView1);
Button bt1 = (Button)findViewById(R.id.button1);
bt1.setOnClickListener(mybtlistener6);

}
Button.OnClickListener mybtlistener6 = new Button.OnClickListener()
{

@Override
public void onClick(View v) {
Animation an1= new RotateAnimation(0.0f,360.0f);
an1.setDuration(2000);
tv.startAnimation(an1);
}
};
}
----------------
<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="啟動" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_vertical|center_horizontal" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="北訊電腦"
            android:textColor="#ff0000"
            android:textSize="30sp" />

    </LinearLayout>

</LinearLayout>

2013年11月20日 星期三

Java 陣列

Java~維整數陣列 : 連續記憶區塊
  資料型態[]  陣列名稱={值一,值二,值三,值四,值五};

ex.
       int[]  a={10,20,30,40,50};

    10     20     30     40        50
a[0]    a[1]    a[2]   a[3]     a[4]     陣列位置索引值
代俵元素
   a[0]=10   a[1]=20   a[2]= 30   a[3]=40  a[4]=50


package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class Array1 extends Activity
{
    private TextView tv7=null;
    private EditText ed1=null,ed2=null,ed3=null,ed4=null,ed5=null;
    private int[] a=new int[5];
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.array1);

tv7 =(TextView)findViewById(R.id.textView7);
ed1 =(EditText)findViewById(R.id.editText1);
ed2 =(EditText)findViewById(R.id.editText2);
ed3 =(EditText)findViewById(R.id.editText3);
ed4 =(EditText)findViewById(R.id.editText4);
ed5 =(EditText)findViewById(R.id.editText5);

Button bt1 = (Button)findViewById(R.id.button1);
Button bt2 = (Button)findViewById(R.id.button2);
bt1.setOnClickListener(mybtlistener4);
bt2.setOnClickListener(mybtlistener4);

}
Button.OnClickListener mybtlistener4 = new Button.OnClickListener()
{

@Override
public void onClick(View v)
{

switch (v.getId())
{
case R.id.button1:
{

a[0]=Integer.parseInt(ed1.getText().toString());
a[1]=Integer.parseInt(ed2.getText().toString());
a[2]=Integer.parseInt(ed3.getText().toString());
a[3]=Integer.parseInt(ed4.getText().toString());
a[4]=Integer.parseInt(ed5.getText().toString());
int max=0;
for ( int i=0; i<a.length ;i++ )
{
if (a[i]> max)
    max=a[i];
}
tv7.setText(String.valueOf(max));
break;
}
case R.id.button2:
{
tv7.setText("");
ed1.setText("");
ed2.setText("");
ed3.setText("");
ed4.setText("");
ed5.setText("");
break;
}
}
}

};


}

-----------------------
<?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"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="數值一:" />

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="number" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="數值二:" />

        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="number" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="數值三:" />

        <EditText
            android:id="@+id/editText3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="number" >

            <requestFocus />
        </EditText>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="數值四:" />

        <EditText
            android:id="@+id/editText4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="number" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="數值五:" />

        <EditText
            android:id="@+id/editText5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="10"
            android:inputType="number" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="最大值" />

        <TextView
            android:id="@+id/textView7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="right" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="執行" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="清除" />

    </LinearLayout>

</LinearLayout>

動畫轉場Animation

進場    Animation  元件1=AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left);
            ImageSwitcher.setInAnimation(元件1);

退場   Animation  元件1=AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);
            ImageSwitcher.setOutAnimation(元件1);

package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.*;

public class Imageswitch1 extends Activity
{
    private ImageSwitcher is1=null;
   
   
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.imageswitch1);

is1=(ImageSwitcher)findViewById(R.id.imageSwitcher1);

Animation in=AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left);
Animation out=AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);
is1.setInAnimation(in);
is1.setOutAnimation(out);

Button bt1=(Button)findViewById(R.id.button1);
Button bt2=(Button)findViewById(R.id.button2);

bt1.setOnClickListener(mybtlistener3);
bt2.setOnClickListener(mybtlistener3);

}
Button.OnClickListener mybtlistener3 = new Button.OnClickListener()
{

@Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.button1:
{
is1.showPrevious();
break;
}
case R.id.button2:
{
is1.showNext();
break;
}
}
}

};

}
---------------------

20121120課程ImageSwitcher


ImageSwitcher:

package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class Imageswitch1 extends Activity 
{
    private ImageSwitcher is1=null;
    
    
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.imageswitch1);
is1=(ImageSwitcher)findViewById(R.id.imageSwitcher1);
Button bt1=(Button)findViewById(R.id.button1);
Button bt2=(Button)findViewById(R.id.button2);
bt1.setOnClickListener(mybtlistener3);
bt2.setOnClickListener(mybtlistener3);
}
Button.OnClickListener mybtlistener3 = new Button.OnClickListener()
{

@Override
public void onClick(View v) 
{
switch (v.getId())
{
case R.id.button1:
{
is1.showPrevious();
break;
}
case R.id.button2:
{
is1.showNext();
break;
}
}
}
};
}
-----------------
<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="412dp" >

        <ImageSwitcher
            android:id="@+id/imageSwitcher1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/a10" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/a11" />

        </ImageSwitcher>

    </LinearLayout>
----------------------




2013年11月18日 星期一

20121118課程

LinearLayout:水平
                     垂直

TextViewl文字顯示元件
EditText; 文字輸入元件
   getTextl()取得文字:
            setText():設定文字


實體元件設定
     元件名稱.findViewById(R.id.name);
Button觸發事件
 元件‧setOnClickListener(類別名稱);
 Button.OnClicListener 類別名稱 = new Button.OnClickListener()
   {  
          public void onClick(View v)
         {
             [動作函式]
         }
    };
元件‧方法()=>物件導向第二原理 

元件‧屬性=>物件導向第一原理
例:Button,weight=0.5;
   
package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class Hope1 extends Activity
{
private EditText et1=null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.hope1);

et1 = (EditText)findViewById(R.id.editText1);
Button bt1 = (Button)findViewById(R.id.button1);
Button bt2 = (Button)findViewById(R.id.button2);

bt1.setOnClickListener(MyListener1);
}
Button.OnClickListener MyListener1 = new Button.OnClickListener()
{

public void onClick(View v)
{
switch (v.getId())
{
case R.id.button1:
{
break;
}
case R.id.button2:
{
break;
}
}

   }

};

}
------------------------------------
顯示元件:Toast
Toast.makeText(this,string,duration).show();
this  鄭在執行中類別元件
string 輸出訊息
duration 顯示時間

Edit Text 取值
CharSequence sname = et1.getText();
序列字元




public void onClick(View v)
{
switch (v.getId())
{
case R.id.button1:
{
CharSequence sname = et1.getText();
Toast.makeText(getApplicationContext(), sname,1000).show();
break;
}
case R.id.button2:
{
et1.setText("");
break;
}
}

   }
--------------------------
ImageView 圖片顯示元件
package com.example.theoryproject1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
public class Imagebasic1 extends Activity
{
private ImageView iv1 =null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.imagebasic1);
iv1=(ImageView)findViewById(R.id.imageView1);

Button bt1=(Button)findViewById(R.id.button1);
Button bt2=(Button)findViewById(R.id.button2);
Button bt3=(Button)findViewById(R.id.button3);

bt1.setOnClickListener(mybtlistener2);
bt2.setOnClickListener(mybtlistener2);
bt3.setOnClickListener(mybtlistener2);
}
Button.OnClickListener mybtlistener2 = new Button.OnClickListener()
{

@Override
public void onClick(View v) {
switch (v.getId())
{
case R.id.button1:
{
iv1.setImageResource(R.drawable.a10);
break;
}
case R.id.button2:
{
iv1.setImageResource(R.drawable.a11);
break;
}
case R.id.button3:
{
iv1.setImageResource(R.drawable.a12);
break;
}
}

}

};

}
-------------------------------
imagebasic.xml
<?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"
    android:background="@drawable/bg1"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.33"
            android:text="影像一"
            android:drawableLeft="@drawable/ju27"/>

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.33"
            android:text="影像二"
            android:drawableLeft="@drawable/ju28"/>

        <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.34"
            android:text="影像三"
            android:drawableLeft="@drawable/ju29"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/a10" />

    </LinearLayout>

</LinearLayout>
-----------------------

課程大綱 2013/11/15

課程大綱 2013/11/15
Android
1.      ViewSwitch 視圖動畫切換
2.      TextSwitch 文字
3.      AnimationSwitch 動畫
4.      FlipperSwitch 電子書
5.      Transaction轉場
6.      畫面動畫
7.      補間甕畫
8.      情境動畫
9.      進階Webview功能
10.  處空原理
11.  ImageSwitch


Jquery
1 選取器
2 進階選取器種類
3 各式元件取值方式
4  CSS JQuery
5  Class JQuery
6  Hover 事件
7  Toggle 事件
分頁功能
輪播器
10  XML處理方式
11  JSon資料處理
12  CVS資料處理
13  Animation網頁式動畫
14  DragDrop


JQuert Mobile
1 基礎畫面版
2  ListView使用方法
進階ListView使用方法
4  Nav導覽列設計
按鈕超連結使用
構圖規劃
各種對話方塊設計
Android控制JQuery資料

環境整合
1  Android環境
2  WAMP環境
網際網路環境
4   JQuery函數庫引入
    JQuery UI函數庫引入
5            JQueryMobil 函數庫引入

Android 架構
import android.app.Activity;
import android..os.Bundle;
import android.widget.*;

class 類別名稱(自訂名稱)extends(繼承) Activity(父類別機動程式)
{
        Protected void onCreate(bundle s) //建立App生命週期開始

{
        super.onCreate(s);


 }
}
1.      private :私有的
2.      public : 公有的
3.      Protected :保護的







2013年11月16日 星期六

環境整合內容















1.Android 環境
2.WAMP環境
3.網際網路環境
4.JQuery函數庫引入 JQery UI 函數庫引入
 5.JQueryMobil函數庫引入

Android 程式架構
 import android.app.Activity; //App 機動程式函數庫
 import android.os.bundle; //App 訊息函數庫,1.保留訊息‧2.參數資料傳輸
 import android.widget.*; //組件函數庫,視覺元件
 class 類別名稱(自訂) extends(繼承) Activity(父類別機動程式)
{
 protected void onCreat(Bundlw s) //建立生命週期開始
 { super.onCreate(s);

 }
 }
 環境建立
 1.Android IDE for eclipse ->JDK6.0 or JDK7.0(Android Studio)
2.Android SDK 到 http://developer.android.com/sdk/index.html 下載
3.建立workspace資料夾,例:myproject
4.模擬器建立 用5.4 SD卡指定1024 
第一個專案建立
1.建立專案
1.new Android App Project 2.other/Android/android application programe 名稱:TheoryProject1
2.建立檔案 建好專案急建立檔案
      1.刪掉AActivity 及 xml layout 檔
      2.建立自訂Activity及xml layout 檔
      src/theoryproject1下new/class Name:Hope1 superclass:android.app.Activity 按下finish
     *自訂Activity package com.example.theoryproject1;
       import android.app.Activity;
       import android.os.Bundle; //overwite 後增加
       public class Hope1 extends Activity
      {
          // 按右建sourse/Overwrite/implement Methods  @Override
         protected void onCreate(Bundle savedInstanceState)
         {
                 // TODO Auto-generated method stub
                    super.onCreate(savedInstanceState);
           }
      }
   *自訂xml layout name:hope1 與Hope1配合
    <?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"
    android:orientation="vertical"
    android:background="@drawable/bg1" >

   </LinearLayout>
   @+drawable/bg1
   @drawable/bg1
   以上兩者不同意義
   *在Hope1.java設定R檔相關
       setContentView(R.layour.hope1);
 3.了解環境
      1.src:Java原始檔
      2.gen:R關聯檔=>layout與src的連結,用findViewById()
      3.assets:網頁檔或其他非編譯資源檔
      4.bin:值行檔和APK封裝檔
      5.libs:第三方函數庫檔
      6.res:資源檔
           string:字串資料
           drawable:圖片,動畫資料 800dp mdpi大於120 大於1000
           menu:選單資料
           layout:版面
          raw:影片,音樂
          animation:動畫 手機像素單位dp及兩個pixl 字型單位sp
      7.AndroidManifast.xml:主設定檔
        java+layout==>  R ==> AndroidManifast.xml ==>RUN==>apk