-1
私は最近アンドロイドスタジオで作業を始めました。私は、SQLを追加する前にアプリのUIを作ろうとしています。どのような方法でも、私はテキストボックスでTableLayoutを使用しようとし、ユーザーの入力を受け取り、そのテーブルに挿入しようとしました。それは動作しません。変数firstName
が実際のTextViewあるandroid.support.v7.widget.AppCompatEditText {...}
fName.setText(firstName + "");
、そう:。私はあなたのコード行で[1]
package com.example.tj_n126.firstappattempt;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.
public class MainActivity extends AppCompatActivity {
private TextView mTextMessage;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
mTextMessage.setText(R.string.title_home);
return true;
case R.id.navigation_dashboard:
mTextMessage.setText(R.string.title_dashboard);
return true;
case R.id.navigation_notifications:
mTextMessage.setText(R.string.title_notifications);
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView lastNameDisplay = findViewById(R.id.lNameTxt);
TextView firstNameDisplay = findViewById(R.id.nameTxt);
TextView phoneNumDisplay = findViewById(R.id.phoneTxt);
TextView emailDisplay = findViewById(R.id.emailTxt);
TextView accBalDisplay = findViewById(R.id.accBal);
firstNameDisplay.setText("First");
lastNameDisplay.setText("Last");
phoneNumDisplay.setText("Phone");
emailDisplay.setText("Email");
accBalDisplay.setText("Balance");
final Button newUserButton = findViewById(R.id.newUserButton);
newUserButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
//this is for inputs on a separate page
setContentView(R.layout.layout2);
final TextView lastName = findViewById(R.id.lastName);
final TextView firstName = findViewById(R.id.firstName);
final TextView phoneNumber = findViewById(R.id.phoneNumber);
final TextView email = findViewById(R.id.emailAddress);
final TextView accountBalance = findViewById(R.id.accountAmount);
Button submitBtn = findViewById(R.id.submitBtn);
submitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
setContentView(R.layout.activity_main);
//These are the textboxes in the table
TextView fName = findViewById(R.id.fName);
TextView lName = findViewById(R.id.lName);
TextView phone = findViewById(R.id.phone);
TextView emailAdd = findViewById(R.id.email);
TextView balance = findViewById(R.id.Balance);
fName.setText(firstName + "");
lName.setText(lastName + "");
phone.setText(phoneNumber + "");
emailAdd.setText(email + "");
balance.setText(accountBalance + "");
}
});
}
});
mTextMessage = (TextView) findViewById(R.id.message);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
}
}
[1]: https://i.stack.imgur.com/8CfWD.png