2017-11-20 5 views
0

これは初心者/嫌いな質問ですが、私はInputActivity.javaとactivity_input.xmlをデータの入力に使用したいと思います。入力のためのコードを以下に示す通りである:自分のアプリケーションの出力部分のアンドロイドスタジオ2.3での入力と出力

InputActivity.java

package com.lukmanyahoo.denny.myapplication; 

import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 

public class InputActivity extends AppCompatActivity { 

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

    //Send data to HasilActivity.java 

} 

activity_input.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 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" 
    tools:context="com.lukmanyahoo.denny.myapplication.InputActivity"> 

    <EditText 
     android:id="@+id/editText" 
     android:layout_width="569dp" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="16dp" 
     android:layout_marginLeft="636dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="15dp" 
     android:ems="10" 
     android:hint="@string/umur" 
     android:inputType="number" 
     app:layout_constraintBottom_toTopOf="@+id/editText" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     tools:ignore="DuplicateIds,NotSibling,RtlHardcoded" 
     app:layout_constraintVertical_bias="0.251" /> 

    <EditText 
     android:id="@+id/editText2" 
     android:layout_width="569dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="16dp" 
     android:ems="10" 
     android:hint="@string/daerah" 
     android:inputType="textPersonName" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/editText" 
     tools:ignore="MissingConstraints,RtlHardcoded" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:text="@string/jurusan" 
     android:textSize="30sp" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     tools:ignore="MissingConstraints" 
     android:layout_marginTop="32dp" 
     app:layout_constraintTop_toBottomOf="@+id/editText2" 
     android:layout_marginStart="16dp" 
     android:layout_marginEnd="16dp" /> 

    <RadioGroup 
     android:id="@+id/radioGroup" 
     android:layout_width="569dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="16dp" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/textView" 
     tools:ignore="RtlHardcoded"> 

     <RadioButton 
      android:id="@+id/radioButton" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/informatika" /> 

     <RadioButton 
      android:id="@+id/radioButton2" 
      android:layout_width="569dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="@string/sistem_informasi" 
      tools:layout_editor_absoluteX="16dp" 
      tools:layout_editor_absoluteY="178dp" /> 

    </RadioGroup> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="569dp" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginStart="16dp" 
     android:layout_marginTop="16dp" 
     android:text="@string/kirim" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/radioGroup" 
     tools:ignore="RtlHardcoded" /> 

</android.support.constraint.ConstraintLayout> 

コードを以下に示す:

HasilActivity.java

package com.lukmanyahoo.denny.myapplication; 

import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 

public class HasilActivity extends AppCompatActivity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_hasil); 
    } 
} 
これを答える時間を割いて210の

activity_hasil.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 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" 
    tools:context="com.lukmanyahoo.denny.myapplication.HasilActivity"> 

    <TableLayout 
     android:layout_width="568dp" 
     android:layout_height="791dp" 
     android:layout_marginBottom="16dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     android:layout_marginTop="16dp" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintVertical_bias="0.0"> 

     <TableRow 
      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="@string/umur" 
       android:textStyle="bold" /> 

      <TextView 
       android:id="@+id/textView3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text=" " 
       tools:layout_editor_absoluteX="58dp" 
       tools:layout_editor_absoluteY="169dp" /> 
     </TableRow> 

     <TableRow 
      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="@string/daerah" 
       android:textStyle="bold" /> 

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

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

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

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

    </TableLayout> 

</android.support.constraint.ConstraintLayout> 

感謝。私はここで質問をするのが新しいです。

答えて

0

あなたInputActivityで

パブリッククラスInputActivityが:)

あるAppCompatActivity {

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

//Send data to HasilActivity.java 
Intent intent = new Intent(this, HasilActivity.class); 
// put your data here 
intent.putExtra("value_one", editText.getText().toString().trim()); 
intent.putExtra("value_two", editText2.getText().toString().trim()); 
startActivity(intent) 

} 

とあなたのHasilActivityで

public class HasilActivity extends AppCompatActivity { 

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

    String value = getIntent().getStringExtra("value_one"); 
    String value2 = getIntent().getStringExtra("value_two"); 
} 
} 

を拡張