2012-06-25 4 views
0

와 SQLite는이 -ANDROID :의 ListView

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

    <EditText 
     android:id="@+id/etClassName" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:layout_marginTop="10dp" 
     android:layout_marginBottom="10dp" 
     android:hint="@string/className"/> 


    <EditText 
     android:id="@+id/etAssignmentName" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" 
     android:ems="10" 
     android:hint="@string/assignmentName"/> 

    <EditText 
     android:id="@+id/etDueDate" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:ems="10" 
     android:layout_marginBottom="20dp" 
     android:hint="@string/dueDate" /> 


    <EditText 
     android:id="@+id/etNotes" 
     android:layout_width="match_parent" 
     android:layout_height="194dp" 
     android:ems="10" 
     android:inputType="textMultiLine" 
     android:layout_marginBottom="5dp" 
     android:hint="@string/notes"/> 


    <LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:orientation="horizontal"> 
     <Button 
      android:id="@+id/bAddAssignments" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/addAssignment" 
      android:layout_weight="1" /> 

     <Button 
      android:id="@+id/bViewAssignments" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/viewAssignments" 
      android:layout_weight="1"/> 
    </LinearLayout> 
</LinearLayout> 

- - 이것은 내 레이아웃은 지금까지 입력 할 수있는 추가 버튼을 클릭 할 수있는 할당 이름을 표시하도록되어 해당 페이지로 당신을 제공합니다 귀하의 과제를 보려면 클릭하십시오 -

<?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" > 

    <ListView 
     android:id="@+id/list" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.63" > 
    </ListView> 

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

     <Button 
      android:id="@+id/bNewAssignment" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/newAssignment" /> 

     <Button 
      android:id="@+id/bdeleteAssignment" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/deleteAssignment" /> 
    </LinearLayout> 

</LinearLayout> 

내 문제는 내 첫 레이아웃에서 데이터를 추적 할 때 두 번째 레이아웃을 채우는 방법을 모르겠다는 것입니다. 두 번째 레이아웃은 사용자가리스트 뷰를 채우기 위해 입력 한 내용을 어떻게 알 수 있습니까?

저는 현재 dbadapter 클래스 (도우미 클래스가있는), 엔트리 클래스 (엔트리 객체 생성) 및 assignmentclass 목록보기)

어떤 아이디어입니까?

+0

문제를 이해할 수 없습니다. 추가 버튼을 클릭하고 주 레이아웃으로 두 번째 XML을 사용하여 새 활동을 시작하고 목록을 채 웁니다. – Barak

+0

실제 질문은 무엇인지 알기가 어렵습니다. '두 번째 페이지에 나열되는 항목을 만드는 방법'은 무엇을 의미합니까? 또한 너무 많은 관련성이없는 코드 –

+0

예, 설명하기가 어렵습니다. 기본적으로 나는 다른 페이지에서 데이터베이스 결과를 게시하는 방법을 모르겠습니다. –

답변

1

당신에게 채워진 배열을주는 어댑터를 배열

  • 만들기 인 텐트 번들에서.

    당신이 의도를 설정하면, 당신은 추가로 THER 다음 수업에 필요한 데이터 넣어 (여기 가정 문자열을 수 있지만, 다른 형태의) : 새 클래스에서

    Intent myIntent = new Intent(YourActivity.this, NewActivity.class); 
    myIntent.putExtra("Data1", data1var); 
    myIntent.putExtra("Data2", data2var); 
    YourActivity.this.startActivity(myIntent); 
    

    :

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
    
        Bundle extras = getIntent().getExtras(); 
        if (extras != null) { 
         String value1 = extras.getString("Data1"); 
         String value2 = extras.getString("Data2"); 
        } 
        //use your passed strings 
    }  
    
  • +0

    도움 주셔서 감사합니다. –

    0

    문제에 대한 설명이 다소 모호합니다. Lars Vogella가 ListView와 함께 SQLLite를 사용하는 방법에 대해 작성한 tutorials 중 하나를 참조 할 수 있습니다. 그들은 모든 것을 멋지고 단순하게 설명합니다. 나는 당신이 그곳에서 당신의 답을 찾을 것이라고 확신합니다!

    업데이트 : InputActivity에서 추가 버튼의

    OnClickListener를 :

    • (당신과 함께 DatabaseHelper) 데이터베이스
    • 목록 항목에 사용자 입력을 추가하는 것은 당신에게를 포함하여 두 번째 활동을 시작 ListView

    목록 제작 :

    • 당신이 필요로하는 데이터를 전달 작성하여 DatabaseHelper 데이터베이스
    • 에서 원하는 레코드 배열을 채워 보자 예를 들어 그것을
    +0

    나는 그랬다. 그리고 나는 실제로 내가 동일한 페이지에 데이터베이스 결과를 게시하는 예제만을 찾을 수 있다고 말했을 때 언급 한 것이다. –