Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > android จะทำปุ่ม button แสดงรูปภาพ next และ back เลื่อนแสดงรูปภาพสลับไปมาครับ



 

android จะทำปุ่ม button แสดงรูปภาพ next และ back เลื่อนแสดงรูปภาพสลับไปมาครับ

 



Topic : 090236

Guest




ผมเก็บรูปไว้ใน raw อยากจะทำปุ่ม button next และ back สำหรับสลับรูปตรับ



Tag : Mobile, Android, JAVA







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-03 22:49:08 By : Bee View : 2220 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ใช้พวก ViewAnimator ครับ ลองดูตัวอย่างนี้ครับ



Go to : ViewAnimator - Android Widgets Example






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 09:48:32 By : mr.win
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ผมเคยเขียนไว้ครับ ลองเอาไปดูเผื่อจะมีประโยชน์ครับ

activity_uniform.xml
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/Header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="10dp"
        android:layout_y="12dp"
        android:text="ชุดประจำชาติ"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <ImageButton
        android:id="@+id/btnBack"
        android:layout_width="45dp"
        android:layout_height="45dp"
        android:layout_x="272dp"
        android:layout_y="1dp"
        android:background="@android:color/transparent" 
        android:src="@drawable/icon_back" />

    <ImageButton
        android:id="@+id/back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="59dp"
        android:layout_y="378dp"
        android:background="@android:color/transparent" 
        android:src="@drawable/back_button" />

    <ImageButton
        android:id="@+id/next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="220dp"
        android:layout_y="378dp"
        android:background="@android:color/transparent" 
        android:src="@drawable/next_button" />

    <ViewAnimator
        android:id="@+id/viewAnimator1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="45dp"
        android:layout_y="86dp" >

		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_brunei" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="บรูไนดารุสซาลาม " />
		    </TableRow>

		</TableLayout>
		
		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_cambodia" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="ราชอาณาจักรกัมพูชา " />
		    </TableRow>
		</TableLayout>		
		
		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_indonisiaload" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="สาธารณรัฐอินโดนีเซีย" />
		    </TableRow>
		</TableLayout>


	<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_laos" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="สาธารณรัฐประชาธิปไตยประชาชนลาว" />
		    </TableRow>
		</TableLayout>
		
	<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_malasia" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="ประเทศมาเลเซีย" />
		    </TableRow>
		</TableLayout>

		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_philipines" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="สาธารณรัฐฟิลิปปินส์ " />
		    </TableRow>
		</TableLayout>
		
		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_singkapore" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="สาธารณรัฐสิงคโปร์  " />
		    </TableRow>
		</TableLayout>	
		
		
		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_thailand" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="ราชอาณาจักรไทย  " />
		    </TableRow>
		</TableLayout>	
		
		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_vietnam" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="สาธารณรัฐสังคมนิยมเวียดนาม  " />
		    </TableRow>
		</TableLayout>		
		
		<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
		    xmlns:tools="http://schemas.android.com/tools"
		    android:layout_width="match_parent"
		    android:layout_height="match_parent" >
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <ImageView
				    android:layout_width="236dp"
				    android:layout_height="match_parent"
				    android:src="@drawable/uniform_myanmar" >
				</ImageView>	
			</TableRow>
			
		    <TableRow 
		        android:layout_width="fill_parent"
		        android:layout_height="wrap_content">
			    <TextView
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:gravity="center"
	            android:text="สหภาพพม่า  " />
		    </TableRow>
		</TableLayout>				
				
		
    </ViewAnimator>

</AbsoluteLayout>


Code (Android-Java)
package com.example.asian;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageButton;
import android.widget.ViewAnimator;

public class UniformActivity extends Activity {

	ViewAnimator va;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        setContentView(R.layout.activity_uniform);
        
        
        va = (ViewAnimator) findViewById(R.id.viewAnimator1);

        final Animation in = AnimationUtils.loadAnimation(this,
                android.R.anim.slide_in_left);
        final Animation out = AnimationUtils.loadAnimation(this,
                android.R.anim.slide_out_right);
   
        va.setInAnimation(in);
        va.setOutAnimation(out);
        
        va.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	va.showNext();
	        }
	    });
        
        // Back
        ImageButton btnBack = (ImageButton) findViewById(R.id.back);
        btnBack.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	va.showPrevious();
            }
        });
        
        
        // Next
        ImageButton btnNext = (ImageButton) findViewById(R.id.next);
        btnNext.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	va.showNext();
            }
        });  
        
        
        
        
        // Back to Home
        final ImageButton btnHome = (ImageButton) findViewById(R.id.btnBack);
        // Perform action on click
        btnHome.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
            	// Open History
            	Intent newActivity = new Intent(UniformActivity.this,HomeActivity.class);
            	startActivity(newActivity);
            }
        });
    }


    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    
}

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-04 09:50:44 By : mr.win
 

 

No. 3

Guest


ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-05 08:31:48 By : Bee
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-05 09:16:38 By : mr.win
 


 

No. 5

Guest


แล้วถ้าใช้จาก json ล่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-06 22:43:41 By : Bee
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : android จะทำปุ่ม button แสดงรูปภาพ next และ back เลื่อนแสดงรูปภาพสลับไปมาครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่