Go Back   Android Forums > Android Development > Application Development > App Inventor

test: Reply
 
LinkBack Thread Tools
Old July 9th, 2012, 02:20 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jul 2012
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default [ASK] Parsing EditText Value on new Activity

Hi guys,i've just start learning android development and i've some problems with my android program. i'll be glad if there's someone who could help

here's d code,
at src/com.android.tes/ :
  • TesActivity.java
    Code:
    package com.android.tes;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    
    public class TesActivity extends Activity implements OnClickListener{
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            Button button1 = (Button) findViewById(R.id.button1);
            button1.setOnClickListener(this);
        }
        public void onClick(View view){
            Intent intent = new Intent(this, TesActivity2.class);
            startActivity(intent);
        }
    }
  • TesActivity2.java
    Code:
    package com.android.tes;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.EditText;
    import android.widget.TextView;
    
    public class TesActivity2 extends Activity{
        @Override
        public void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.secondlayout);
            
            TextView teks = (TextView) findViewById(R.id.teks);
            EditText edit1 = (EditText) findViewById(R.id.edit1);
            
            int val = Integer.parseInt(edit1.getText().toString());
            teks.setText(Integer.toString(val));        
        }
    }

yang di res/layout/ :
  • main.xml
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <EditText
            android:id="@+id/edit1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </EditText>
        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button" />
    
    </LinearLayout>
  • secondlayout.xml
    Code:
    <?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" >
    
        <TextView
            android:id="@+id/teks"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello2"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    
    </LinearLayout>

yang di res/values/ :
  • strings.xml
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <string name="hello">Hello World, TesActivity!</string>
        <string name="hello2">Hello World, TesActivity2!</string>
        <string name="app_name">Tes</string>
    
    </resources>

AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.tes"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".TesActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".TesActivity2"
            android:label="@string/app_name" >
        </activity>
    </application>

</manifest>
the program works if the result and the source are at the same layout, but i don't know how to make it works with different activity.
Thanks

Advertisements
chikatz is offline  
Reply With Quote
sponsored links
Old July 18th, 2012, 10:10 AM   #2 (permalink)
Junior Member
 
darkwispr's Avatar
 
Join Date: Jul 2012
Location: PR
Posts: 46
 
Device(s): Samsung Admire
Carrier: Not Provided

Thanks: 14
Thanked 12 Times in 7 Posts
Default

Android Training

Thats a tutorial in which a text is passed to another activity and edited to be bigger and bold and anything you want.

Good Luck! [Link is OK]
I think this thread as nothing to do with app inventor?

I think it needs a move. [Android development]
darkwispr is offline  
Last edited by darkwispr; July 18th, 2012 at 10:16 AM.
Reply With Quote
Reply
Tags
edittext, new activity, parse


Go Back   Android Forums > Android Development > Application Development > App Inventor
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:15 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.