0

ユーザーが患者を検索するオプションを持つアプリケーションを作成しています。ユーザーが患者を検索すると、結果がリストビューに表示されます。しかし問題は、下のアプリケーションのスクリーンショットでわかるように、ユーザーが適切に見ることができるほど結果が明るくないことです (患者の検索ボタンの下に、結果は 1234567890、abc、xyz として表示されます。よく見てください。)

患者検索画面

明るくする方法がわかりません。実際の Android デバイスでも同じ問題が発生します。誰か助けてください。

以下は私のコードです:-

SearchPatient.java

public class SearchPatient extends Activity implements PacketListener, OnItemClickListener, TextWatcher
{
private EditText mobileNumber;
private EditText firstName;
private EditText lastName;
private ListView patients;
private ArrayAdapter<String> adapter;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search_patient);
    mobileNumber = (EditText) findViewById(R.id.mobile_number);
    mobileNumber.addTextChangedListener(this);
    firstName = (EditText) findViewById(R.id.first_name);
    firstName.addTextChangedListener(this);
    lastName = (EditText) findViewById(R.id.last_name);
    lastName.addTextChangedListener(this);
    patients = (ListView) findViewById(R.id.patients);
    patients.setOnItemClickListener(this);
    adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1);
    patients.setAdapter(adapter);

    PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
    Login.connection.addPacketListener(this, filter);
}

@Override
protected void onResume()
{
    super.onResume();
    PacketFilter filter = new MessageTypeFilter(Message.Type.chat);
    Login.connection.addPacketListener(this, filter);
}

@Override
protected void onStop()
{
    Login.connection.removePacketListener(this);
    super.onStop();
}

@Override
public void onTextChanged(CharSequence charSequence, int i1, int i2, int i3)
{
    return;
}

@Override
public void afterTextChanged(Editable editable)
{
    adapter.clear();

    String mobileNumber = this.mobileNumber.getText().toString();
    String firstName = this.firstName.getText().toString();
    String lastName = this.lastName.getText().toString();

    if(mobileNumber.equals(""))
        mobileNumber = null;
    if(firstName.equals(""))
        firstName = null;
    if(lastName.equals(""))
        lastName = null;

    searchPatient(mobileNumber, firstName, lastName);
}

@Override
public void beforeTextChanged(CharSequence charSequence, int i1, int i2, int i3)
{
    return;
}

public void searchPatient(View view)
{
    adapter.clear();

    String mobileNumber = this.mobileNumber.getText().toString();
    String firstName = this.firstName.getText().toString();
    String lastName = this.lastName.getText().toString();

    if(mobileNumber.equals(""))
        mobileNumber = null;
    if(firstName.equals(""))
        firstName = null;
    if(lastName.equals(""))
        lastName = null;

    searchPatient(mobileNumber, firstName, lastName);
}

private void searchPatient(String mobileNumber, String firstName, String lastName)
{
    Login.connection.sendPacket(getMessage(buildCommand(mobileNumber, firstName, lastName)));
}

private String buildCommand(String mobileNumber, String firstName, String lastName)
{
    StringBuilder commandBuilder = new StringBuilder();

    commandBuilder.append("##?##");
    commandBuilder.append("##app:patients##");
    commandBuilder.append("##" + mobileNumber + ", " + firstName + ", " + lastName + "##");

    return commandBuilder.toString();
}

private Message getMessage(String body)
{
    Message message = new Message("friend@domain", Message.Type.chat);
    message.setBody(body);

    return message;
}

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
{
    String[] record = adapterView.getItemAtPosition(i).toString().split("\\,");
    if(record.length == 1)
        return;

    Intent patientDetails = new Intent(getApplicationContext(), PatientDetails.class);
    patientDetails.putExtra(PatientDetails.ACTION, PatientDetails.READ_PATIENT);
    patientDetails.putExtra(PatientDetails.RECORD, record);

    startActivity(patientDetails);
}

@SuppressLint("NewApi")
@Override
public void processPacket(Packet packet)
{
    Message message = (Message) packet;
    String reply = message.getBody().trim();

    if(reply.contains("."))
    {
        String[] records = reply.split("\\.");

        if(Build.VERSION.SDK_INT >= 11)
            adapter.addAll(records);
        else
            for(int i = 0; i < records.length; i++)
                adapter.add(records[i]);
    }
    else
        adapter.add(reply);

    adapter.notifyDataSetChanged();
}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    getMenuInflater().inflate(R.menu.menu, menu);
    return true;
}

}

search_patient.xml

<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".SearchPatient" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/mobile_number"/>
<EditText 
    android:id="@+id/mobile_number"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:inputType="number"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/and_or"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/first_name"/>
<EditText 
    android:id="@+id/first_name"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:inputType="text"/>
<TextView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/last_name"/>
<EditText 
    android:id="@+id/last_name"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:inputType="text"/>
<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/search_patient"
    android:onClick="searchPatient"/>
<ListView 
    android:id="@+id/patients"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"/>

</LinearLayout>
4

1 に答える 1