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 - แอฟ แอนดรอยนะครับสอบถามว่า เกี่ยวกับ arraylist และการโชว์ข้อมูลให้เก็บตามที่เราใช้ข้อมูลไว้ใน arraylist นะครับ



 

Android - แอฟ แอนดรอยนะครับสอบถามว่า เกี่ยวกับ arraylist และการโชว์ข้อมูลให้เก็บตามที่เราใช้ข้อมูลไว้ใน arraylist นะครับ

 



Topic : 101415



โพสกระทู้ ( 14 )
บทความ ( 0 )



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




โค๊ดนะครับ ใส่ข้อมูลดังนี้ RA0A00P012450E ข้อมูลจะใส่มาประมาณนี้ตลอดครับแต่จะเปลี่ยนเรื่อยๆโดยยุ่วในลักษณะนี้นะครับ ตอนแสดงผมอยากให้แสดงผมตามนั้น แต่ทุกตัวที่ใส่ไปโดยการแยกสตริงตามโค้ดนะครับ ใครรู้ช่วยตอบหน่อยนะครับ ขออย่างด่วนครับ ขอบคุณครับ
โค้ด MainActivity

Code (Android-Java)
package example.testing;

import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;


public class MainActivity extends Activity {

private EditText getdata;
private Button Ok;
private Button Show;
private ArrayList<String> data;
TextView textView1;
TextView textView2;
TextView textView3;
TextView textView4;
TextView textView5;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


// view matching

getdata = (EditText) findViewById(R.id.editText1);
Ok = (Button) findViewById(R.id.gettext);
textView1 = (TextView)findViewById(R.id.textView1);
textView2 = (TextView)findViewById(R.id.textView2);
textView3 = (TextView)findViewById(R.id.textView3);
textView4 = (TextView)findViewById(R.id.textView4);
textView5 = (TextView)findViewById(R.id.textView5);
data = new ArrayList<String>();


Ok.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
data .add(getdata.getText().toString());
int Len;
String S;
Len = data.size();
for(int i=0;i<Len;i++){
	S = data.get(i).toString();
	cutString(S);
}
}

});
}

//@Override
 //TODO Auto-generated method stub
	
	
	public void cutString(String s){
		String str11,str12,str13,str14,str10,SA;
		ArrayList<String> strArr = new ArrayList<String>();
		str14 = s.substring(1, 2);
		str13 = s.substring(3, 4);
		str12 = s.substring(6, 7);
		str11 = s.substring(8, 10);
		str10 = s.substring(10, 12);
		//txtRTD.setText(str14 + str13 + str12 + str11 + str10);
		strArr.add(str14);
		SA = strArr.toString();
		textView4.setText("Mode : " + SA);
		textView2.setText("Point : " + str13);
		textView5.setText("Pass/Fail : " + str12);
		int intS = Integer.parseInt(str10);
		ArrAddS(intS);
		int intMS = Integer.parseInt(str11);
		ArrAddMS(intMS);
		
	}
	
	public int ArrAddS (int x){
		ArrayList<Integer> arr_value = new ArrayList<Integer>();
		arr_value.add(x);
		totalMS(arr_value);
		return x; 
	}
	public int ArrAddMS (int y){
		ArrayList<Integer> arr_value = new ArrayList<Integer>();
		arr_value.add(y);
		totalS(arr_value);
		return y; 
	}
	
	public void totalS (ArrayList<Integer> arr_value){
		int int_total = 0;
		for(int i = 0 ; i < arr_value.size() ; i++) {
			int_total += (Integer) arr_value.get(i);
		}
		int float_avg;
		float_avg = (int)int_total / arr_value.size();
		String b = String.valueOf(float_avg);
		textView1.setText("Time AVG : " + b + ":");
		return ;
	}
	public void totalMS (ArrayList<Integer> arr_value){
		int int_total = 0;
		for(int i = 0 ; i < arr_value.size() ; i++) {
			int_total += (Integer) arr_value.get(i);
		}
		int float_avg;
		float_avg = (int)int_total / arr_value.size();
		String b = String.valueOf(float_avg);
		textView3.setText(b);
		return ;
	}

}




โค้ด activity_main.xml

Code (XML)
<RelativeLayout 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"
    android:gravity="center_vertical"
    tools:context=".MainActivity" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="49dp"
        android:ems="10" />

    <Button
        android:id="@+id/gettext"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="76dp"
        android:text="บันทึก" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/gettext"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="22dp"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/gettext"
        android:layout_below="@+id/textView1"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView2"
        android:layout_below="@+id/textView2"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView5"
        android:layout_below="@+id/textView5"
        android:text="TextView" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView1"
        android:layout_alignBottom="@+id/textView1"
        android:layout_alignRight="@+id/editText1"
        android:text="TextView" />

</RelativeLayout>


ตามนี้ครับแสดงผมแยกตามสริงที่ substring ไว้นะครับ ส่วนค่าตัวเลขเป็นเวลา หาค่าเฉลี่ยครับ ทุกครั้งที่ใส่เข้ามาค่าเฉลี่ยก็รวมมาแสดงเรื่อยๆอ่ะครับ แต่ผมทำมันออกมาค่าเดียวที่ใส่อ่ะครับ ใครรู้ช่วยผมทีครับ ผมคิดไม่ออกจริงๆครับ ไม่เก่งภาษานี้เท่าไหร่ครับทำครั้งแรก ขอบคุณครับ แล้วก็ทุกค่าที่ substring อยากให้แสดงทุกตัวที่ใส่ข้อมูลเข้ามาด้วยครับ



Tag : Mobile, Android







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-10-07 21:00:24 By : GooDbyJudy View : 945 Reply : 4
 

 

No. 1



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

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

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

ขอภาพประกอบหน่อยครับ






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


 

No. 2



โพสกระทู้ ( 14 )
บทความ ( 0 )



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


ตามนี้ครับ

แบบนี้อ่ะครับ แล้วพอใส่ค่าไปใหม่ RA0A00P023570E
ค่าตัวเลขตรง Time AVG ก็จะไปเป็นค่าเฉลี่ยของตัวเลขเก่าบวกใหม่นะครับ เป็นค่าเฉลี่ยเวลานะครับ ตรง mode ,point ,pass/fail ก็จะเพิ่มตัวอักษรเข้าไปตามที่เราใส่ข้อมูลไปใหม่นะครับ เช่น mode A,A ไปเรื่อยๆแบบนี้อ่ะครับ โค้ดผมมันได้อันเดียวอ่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-10-08 12:57:41 By : GooDbyJudy
 

 

No. 3



โพสกระทู้ ( 14 )
บทความ ( 0 )



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


ใครก็ได้ตอบหน่อยเถอะ ขอร้องแหละครับ แอดมิน คนอื่นๆ ใครที่รู้ นะครับ พีชชชชชชชชชช
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-10-08 19:09:42 By : GooDbyJudy
 


 

No. 4



โพสกระทู้ ( 14 )
บทความ ( 0 )



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


จะไม่ตอบกันหน่อยหรอครับ รอๆยุ่วครับ ทำไม่ได้ ไม่รู้ต้องแก้ยังไงครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-10-09 12:52:40 By : GooDbyJudy
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : Android - แอฟ แอนดรอยนะครับสอบถามว่า เกี่ยวกับ arraylist และการโชว์ข้อมูลให้เก็บตามที่เราใช้ข้อมูลไว้ใน arraylist นะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 04
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 อัตราราคา คลิกที่นี่