I will apologize in advance as I'm a newbie to Java and the mobile environment. I tried to find the answer on Stack Overflow but couldn't find it. The program I have is just crashing the emulator and says:
Unfortunately "program name here" has stopped working.
Below is the Java and XML. It compiles okay.
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
public class IconCMOLogin extends ActionBarActivity {
EditText phlogin,pword,uname;
Button btnSubmit;
String finalstring;
String chp, unm, psw;
Button btn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_icon_cmologin);
phlogin = (EditText)findViewById(R.id.phlogin);
uname = (EditText)findViewById(R.id.uname);
pword = (EditText)findViewById(R.id.pword);
chp = phlogin.getText().toString();
unm = uname.getText().toString();
psw = pword.getText().toString();
btn = (Button)findViewById(R.id.btnsubmit);
/* add in code to create url* (look like this -
https://app.iconcmo.com/index.asp?action=login&phone=6666666660&username=Ashton758&password=qn69e2ry&hidDateTime=1427407069/
new Uri.Builder().scheme("http").authority("app.iconcmo.com").path("/index.asp?action=login&phone=").appendQueryParameter("phlogin")
*/
btnSubmit.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
finalstring = "https://app.iconcmo.com/index.asp?action=login&phone=chp&username=unm&password=psw";
Toast.makeText(IconCMOLogin.this, finalstring,
Toast.LENGTH_SHORT).show();
}
});
/* addListenerOnButton();
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_icon_cmologin, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
*/
}
}
XML
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".IconCMOLogin"
>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/pword"
android:hint="Your Password"
android:layout_below="@+id/uname"
android:layout_alignLeft="@+id/uname"
android:layout_alignStart="@+id/uname"
android:layout_marginTop="76dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/btnsubmit"
android:layout_alignParentBottom="true"
android:layout_alignLeft="@+id/pword"
android:layout_alignStart="@+id/pword" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/phlogin"
android:text="Phone"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="83dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="@+id/uname"
android:layout_below="@+id/phlogin"
android:layout_alignLeft="@+id/phlogin"
android:layout_alignStart="@+id/phlogin"
android:layout_marginTop="46dp" />
</RelativeLayout>
0 comments:
Post a Comment