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 เส้นแดงๆในโค๊ดจาวาตัวนี้มันคือออะไรคับ เกี่ยวกับการที่โปรแกรมรันผ่านแต่ไม่แสดงดาต้าเบสรึปาวคับ



 

Android เส้นแดงๆในโค๊ดจาวาตัวนี้มันคือออะไรคับ เกี่ยวกับการที่โปรแกรมรันผ่านแต่ไม่แสดงดาต้าเบสรึปาวคับ

 



Topic : 120883



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



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






เส้นแดงๆในโค๊ดจาวาตัวนี้มันคือออะไรคับ เกี่ยวกับการที่โปรแกรมรันผ่านแต่ไม่แสดงดาต้าเบสรึปาวคับ


MainActivity.java

Code (Java)
package com.coderefer.thaicreate;




        import android.os.Bundle;
        import android.view.View;
        import android.widget.AdapterView;
        import android.widget.AdapterView.OnItemClickListener;
        import android.widget.ListView;
        import android.widget.SimpleCursorAdapter;
        import android.app.Activity;
        import android.database.Cursor;
        import android.widget.Toast;

public class MainActivity extends Activity {

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

        // get Data from SQLite
        final myDBClass myDb = new myDBClass(this);
        final Cursor myData = myDb.SelectAllData();

        // listView1
        ListView lisView1 = (ListView)findViewById(R.id.listView1);

        SimpleCursorAdapter adapter;
        adapter = new SimpleCursorAdapter(MainActivity.this, R.layout.activity_column, myData
                ,new String[] {"MemberID","Name","Tel"}
                ,new int[] {R.id.ColMemberID, R.id.ColName, R.id.ColTel});

        lisView1.setAdapter(adapter);

        // OnClick Item
        lisView1.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> myAdapter, View myView, int position, long mylng) {

                String MemberID = myData.getString(myData.getColumnIndex("MemberID"));
                Toast.makeText(getApplicationContext(),
                        "Selected MemberID : " + MemberID, Toast.LENGTH_SHORT).show();

            }
        });


    }


}



myDBClass.java
Code (Java)
package com.coderefer.thaicreate;

/**
 * Created by Administrator on 12/1/2559.
 */



        import android.content.Context;
        import android.database.Cursor;
        import android.database.sqlite.SQLiteDatabase;
        import android.database.sqlite.SQLiteOpenHelper;
        import android.util.Log;

public class myDBClass extends SQLiteOpenHelper {


    // Database Version
    private static final int DATABASE_VERSION = 1;

    // Database Name
    private static final String DATABASE_NAME = "mydatabase";

    // Table Name
    private static final String TABLE_MEMBER = "members";

    public myDBClass(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        // Create Table Name
        db.execSQL("CREATE TABLE " + TABLE_MEMBER +
                "(MemberID INTEGER PRIMARY KEY AUTOINCREMENT," +
                " Name TEXT(100)," +
                " Tel TEXT(100));");

        Log.d("CREATE TABLE","Create Table Successfully.");
    }

    // Select All Data
    public Cursor SelectAllData() {
        // TODO Auto-generated method stub

        try {
            SQLiteDatabase db;
            db = this.getReadableDatabase(); // Read Data

            String strSQL = "SELECT  MemberID As _id , * FROM " + TABLE_MEMBER;
            Cursor cursor = db.rawQuery(strSQL, null);

            return cursor;

        } catch (Exception e) {
            return null;
        }

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_MEMBER);

        // Re Create on method  onCreate
        onCreate(db);
    }

}



activity_column.xml
Code (XML)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:id="@+id/ColMemberID"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="MemberID"/>

    <TextView
        android:id="@+id/ColName"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="Name"/>

    <TextView
        android:id="@+id/ColTel"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Tel" />

</LinearLayout>


activity_main.xml
Code (XML)
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tableLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:text="List Member : "
            android:layout_span="1"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </TableRow>

    <View
        android:layout_height="1dip"
        android:background="#CCCCCC" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.1">

        <ListView
            android:id="@+id/listView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        </ListView>

    </LinearLayout>

    <View
        android:layout_height="1dip"
        android:background="#CCCCCC" />

    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dip" >

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="By.. ThaiCreate.Com" />

    </LinearLayout>

</TableLayout>



content_main.xml
Code (XML)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.coderefer.thaicreate.MainActivity"
    tools:showIn="@layout/activity_main">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>





Tag : Mobile, Android, Mobile









ประวัติการแก้ไข
2016-01-14 13:13:23
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-01-14 13:10:10 By : yag00za View : 1003 Reply : 5
 

 

No. 1



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

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

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

มันน่าจะถูก Deprecated (ประกาศยกเลิก) ครับ แต่ยังสามารถใช้งานได้ครับ แต่ใน Version ถัดไป หรือในอีกหลาย ๆ เวอร์ชั่นอาจจะถูกนำออกไปอย่างภาวร






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-01-15 09:13:18 By : mr.win
 


 

No. 2



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



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


ขอบคุณครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-01-16 20:27:24 By : shiowa
 

 

No. 3



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



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


Code กลุ่ม Deprecated (ประกาศยกเลิก) นั้น ยังใช้ได้ แต่ไม่มีพัฒนาเพิ่มเติมแล้ว ดังนั้นจึงแนะนำว่า เปลี่ยนเป็น Code กลุ่มใหม่ เช่น HttpClient -> HttpURLConnection เป็นต้นครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-08-28 11:35:01 By : doanga2007
 


 

No. 4



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

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

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


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


 

No. 5



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



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

จริงมันก็ใช่ได้นะครับ แต่ก็ควรหลีกเลี่ยงไว้ หรือก็ version android ถ้าเกิดต้องการทำต่อในอนาคต เพราะ อันที่แดงๆ อาจจำทำมีปัญหาก็ได้เพราะ api ไม่เจอในรุ่นนั้น
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-09-07 01:47:17 By : heloman
 

   

ค้นหาข้อมูล


   
 

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