Users may see expressions which is defined at inline template, when they use a device with low speed.

In that case, We can use ng-cloak directive.


<div class="well">

            <div class="radio" ng-repeat="button in ['None', 'Table', 'List']">

                <label ng-cloak>

                    <input type="radio" ng-model="data.mode" value="{{button}}" ng-checked="$first"/> {{button}}

                </label>

            </div>

            <div ng-switch on="data.mode" ng-cloak>

                <div ng-switch-when="Table">

                    <table class="table">

                        <thead>

                            <tr>

                                <th>#</th>

                                <th>Action</th>

                                <th>Done</th>

                            </tr>

                        </thead>

                        <tr ng-repeat="item in todos" ng-class="$odd ? 'odd' : 'even'">

                            <td>{{$index + 1}}</td>

                            <td ng-repeat="prop in item">{{prop}}</td>

                        </tr>

                    </table>

                </div>

                <div ng-switch-when="List">

                    <ol>

                        <li ng-repeat="item in todos">

                            {{item.action}}<span ng-if="item.complete">(Done)</span>

                        </li>

                    </ol>

                </div>

                <div ng-switch-default>

                    Select another option to display a layout

                </div>

            </div>

        </div>

* Listing up just local branch

$ git branch

* RB_1.0.1

  master



We should know about 4 essential keywords to control multiroter for flight.


1. Throttle

: We use this throttle function to control each propeller's speed.


2. Roll

- We can move multi-rotor toward left or right by using roll function.

- Roll also means Aileron.


3. Pitch

- We can move multi-rotor toward forward or backward by using pitch function.

- Pitch also means Elevator.


4. Yaw

- We can make multi-rotor rotate clockwise or anticlockwise by using yaw function.

- Yaw also means Rudder




     referenced by Droneskorea.



This example will show how to transfer URI data from an Activity to another Activity.

Please download the sample projects and import these projects into your IDE. ^^


IntentsLabSubmit.zip


What is object? Object is a module with a function which can reuse easily in application development.



Define Objective-C class interface.

@interface ClassName: ParentClass {

   ClassMembers;

}

ClassMethods;

@end

--> you can define instance variables in the ClassMembers.

--> you can define called methods in the ClassMethods.



Add instance variables in a class

@interface Account: NSObject{

   double balance;

   long number;

}

@end




Define class methods

-(void) setNumber: (long) y;     // parameter of a long type

-(long) getNumber();               // returned value of a long type

-(void) setAccount: (long)y andBalance: (double)x;     // parameter more than one

--> (-) means instance method, and (+) menans class method.



Define and initialize class instance

Account* account;

account = [Account alloc];

account = [account init];


or


Account* accunt = [[Account alloc] init];



Call a method

[account displayAccountInfo];

[account setAccountNumber: 1234321];

[account setAccountNumber: 12345334 andBalance: 3145.19];


We can populate an AdapterView such as Listview or GridView by binding the AdapterView instance to an Adapter.

At this example, We will learn to implement simple list using a ListView and BaseAdapter basically.


The steps to implement ListView are the following.


1. Define the XML Layout to display data in the view.


2. Define Java beans Class to save data.


3. Define the view group so that Listview is populated with data. 


4. Define Adapter which is charge of the role of the data management.

: Adater is an interface whose implementations provide data and the display of that data used by the Listview.


5. Define Listview to display on the screen and Listener being called when data is selected.




Defining the XML Layout to display data in the view.

==== sports_item.xml ====

<?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="horizontal" >

    

<TextView 

   android:id="@+id/sportsName"

   android:layout_width="match_parent"

   android:layout_height="wrap_content"

   android:layout_weight="1"

   android:text="야구"

   />

<TextView 

   android:id="@+id/description"

   android:layout_width="match_parent"

   android:layout_height="wrap_content"

   android:layout_weight="1"

   android:text="야구"

   />

<TextView 

   android:id="@+id/memberCount"

   android:layout_width="match_parent"

   android:layout_height="wrap_content"

   android:layout_weight="1"

   android:text="야구"

   />

</LinearLayout>




Defining java beans class to save data.

==== SportsItem.java ====


package com.example.samplelistviewsports;


public class SportsItem {

private String sportsName;

private String description;

private String memberCount;

public SportsItem(String sportsName, String description, String memberCount) {

super();

this.sportsName = sportsName;

this.description = description;

this.memberCount = memberCount;

}


public String getSportsName() {

return sportsName;

}


public void setSportsName(String sportsName) {

this.sportsName = sportsName;

}


public String getDescription() {

return description;

}


public void setDescription(String description) {

this.description = description;

}


public String getMemberCount() {

return memberCount;

}


public void setMemberCount(String memberCount) {

this.memberCount = memberCount;

}

}




Defining the view group so that Listview populated with data.

==== SportsItemView.java ====

package com.example.samplelistviewsports;


import android.content.Context;

import android.view.LayoutInflater;

import android.widget.LinearLayout;

import android.widget.TextView;


public class SportsItemView extends LinearLayout {


private TextView sportsName;

private TextView description;

private TextView memberCount;

public SportsItemView(Context context, SportsItem item) {

super(context);

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

inflater.inflate(R.layout.sports_items, this, true);

sportsName = (TextView)findViewById(R.id.sportsName);

description = (TextView)findViewById(R.id.description);

memberCount = (TextView)findViewById(R.id.memberCount);

sportsName.setText(item.getSportsName());

description.setText(item.getDescription());

memberCount.setText(item.getMemberCount());

}


}



Defining ListView Adapter.

==== SportsItemViewAdapter.java ====

package com.example.samplelistviewsports;


import java.util.ArrayList;

import java.util.List;


import android.content.Context;

import android.view.View;

import android.view.ViewGroup;

import android.widget.BaseAdapter;


public class SportsListViewAdapter extends BaseAdapter{

private List<SportsItem> items = new ArrayList<SportsItem>();

private Context context;

public SportsListViewAdapter(Context context) {

super();

this.context = context;

}


public void addItem(SportsItem item){

items.add(item);

}

@Override

public int getCount() {

// TODO Auto-generated method stub

return items.size();

}


@Override

public Object getItem(int arg0) {

// TODO Auto-generated method stub

return items.get(arg0);

}


@Override

public long getItemId(int position) {

// TODO Auto-generated method stub

return 0;

}


@Override

public View getView(int position, View convertView, ViewGroup parent) {

SportsItemView itemView = null;

if(convertView == null){

itemView = new SportsItemView(context, items.get(position));

}else{

itemView = (SportsItemView)convertView;

}

return itemView;

}


}

--> getView method is the most important method in this adapter. The view being returned from this method is displayed on the screen as one item.



Defining Listview to display on the screen.

==== SportListView.java ====

package com.example.samplelistviewsports;


import android.content.Context;

import android.widget.BaseAdapter;

import android.widget.ListView;


public class SportListView extends ListView {


public SportListView(Context context) {

super(context);

// TODO Auto-generated constructor stub

}

public void setAdapter(BaseAdapter adapter){

super.setAdapter(adapter);

}


}





Making a codes to excute the app in the MainActivity.

==== MainActivity.java ====

package com.example.samplelistviewsports;


import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.view.ViewGroup;

import android.view.ViewGroup.LayoutParams;


public class MainActivity extends Activity {


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

SportsListViewAdapter adapter = new SportsListViewAdapter(this);

adapter.addItem(new SportsItem("야구", "9명이 하는 베이스볼 게임", "9명"));

adapter.addItem(new SportsItem("축구", "11명이 하는 멋진 게임", "11명"));

SportsListView listView = new SportsListView(this);

listView.setAdapter(adapter);

                listView.setOnItemClickListener(new OnItemClickListener() {


@Override

public void onItemClick(AdapterView<?> parent, View view, int position,

long arg3) {

ListView listView = (ListView) parent;

//SportsItem item = (SportsItem)listView.getItemAtPosition(position);

SportsItem item = (SportsItem)adapter.getItem(position);

                                Toast.makeText(getBaseContext(), item.getSportsName(), Toast.LENGTH_LONG).show();

}

});

LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

setContentView(listView, params);

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}


}




Below is the screen executed this app.

























'Android > Layout' 카테고리의 다른 글

Set borders by using the LinearLayout  (0) 2014.02.01

We can remove the default title bar provided in the system. 

There are two ways like the following examples.


The first way,

==== MainActivity.java ====

package com.example.samplebitmapwidget;


import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.view.Window;


public class MainActivity extends Activity {


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

setContentView(R.layout.activity_main);

}

}


: we can remove the title bar by calling requestWindowFeature() method like the above. This method should be called before being called setContentView() method.




The second way,

==== AndroidManifest.xml ====

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.samplebitmapwidget"

    android:versionCode="1"

    android:versionName="1.0" >


    <uses-sdk

        android:minSdkVersion="8"

        android:targetSdkVersion="18" />


    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@android:style/Theme.Light.NoTitleBar" >

        <activity

            android:name="com.example.samplebitmapwidget.MainActivity"

            android:label="@string/app_name" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest>


: We can remove the title bar by specifying "@android:style/Theme.Light.NoTitleBar" as a value of the "android:theme" attribute.



the following is the feature removed the default title.



It's important that we specify the appropriate input type that the user expects,such as an email address, phone number, or just plain text when they enter some text in every text field.


We can specify the appropriate input type like the following.

==== activity_main.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:background="#ffcccccc"

android:orientation="vertical" >

<!-- The button for closing the keypad -->

<Button 

   android:id="@+id/btnCloseKeyPad"

   android:layout_width="match_parent"

   android:layout_height="wrap_content"

   android:text="closing keypad"

   />

<TextView

android:id="@+id/caption01"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: text|textCapWords"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox01"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="text|textCapWords

/>

<TextView

android:id="@+id/caption02"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: number|numberSigned|numberDecimal"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox02"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="number|numberSigned|numberDecimal

/>

<TextView

android:id="@+id/caption03"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: textEmailAddress"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox03"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="textEmailAddress"

/>

<TextView

android:id="@+id/caption04"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: textPassword"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox04"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="textPassword"

/>

<TextView

android:id="@+id/caption05"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: phone"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox05"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="phone"

/>

<TextView

android:id="@+id/caption06"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: date"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox06"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="date"

/>

<TextView

android:id="@+id/caption07"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#ff0000ff"

android:text="inputType: time"

android:textStyle="bold"

android:textSize="18dp" 

android:textColor="#ffffffff"

/>

<EditText

android:id="@+id/editTextBox07"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:padding="10px"

android:textSize="16dp"

android:inputType="time"

/>

</LinearLayout>


: We can specify the input type for out text field by adding the android:inputType attribute to the EditText element.


Here are several possible values documented with the android:inputType attribute.



'Android > ㄴ on-screen keyboard' 카테고리의 다른 글

Closing an on-screen keyboard  (0) 2014.02.07

For example, we should let us close an on-screen keyboard, after we log in successfully.

In that case, We can close the keybord programmatically. 


==== MainActivity.java ====

package com.example.samplekeypad;


import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.inputmethod.InputMethodManager;

import android.widget.Button;

import android.widget.Toast;


public class MainActivity extends Activity {


@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button btnCloseKeypad = (Button)findViewById(R.id.btnCloseKeyPad);

btnCloseKeypad.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

/**

* We can close the on-screen keyboard by using InputMethodManager.

*/

InputMethodManager inputManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);

inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);


Toast.makeText(getBaseContext(), "스크린 키보드를 닫습니다.", Toast.LENGTH_SHORT).show();

}

});

}


@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}


}


: We can close an on-screen keyboard by calling hideSoftInputFromWindow() method in InputMethodManager Class.


'Android > ㄴ on-screen keyboard' 카테고리의 다른 글

Specifying The Keyboard Type  (0) 2014.02.07

We just need to include the mybatis-x.x.x.jar file in the classpath to use MyBatis.

We can download it at "https://github.com/mybatis/migrations/releases".

If we will use Maven, we just add the following dependency to our pom.xml


==== pom.xml ====

<dependency>

  <groupId>org.mybatis</groupId>

  <artifactId>mybatis</artifactId>

  <version>x.x.x</version>

</dependency>

: we can find the above source code at "http://mvnrepository.com/".


1. Setting the configuration XML file

The configuration XML file contains settings for the core of the MyBatis system, including a DataSouce for acquiring database connection instances. 

Here is simple example.


==== mybatis.xml ====

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"  "http://mybatis.org/dtd/mybatis-3-config.dtd">


<configuration>

    <!-- Elements should be coded keeping order. -->

   

    <!-- including a property's file -->

    <properties resource="mybatis.properties" />


    <typeAliases>

        <typeAlias alias="GoodsCmnDto" type="com.world.test.dto.GoodsCmnDto"/>

    </typeAliases>

    

    

    <!-- the setting of Database Connection -->

    <environments default="development">

        <environment id="development">

            <transactionManager type="JDBC" />

            <dataSource type="POOLED">

                <property name="driver" value="${driver}" />

                <property name="url" value="${url}" />

                <property name="username" value="${username}" />

                <property name="password" value="${password}" />


            </dataSource>

        </environment>

    </environments>

   

    <!-- sql Mappers -->

    <mappers>

        <mapper resource="com/mobile/test/service/sqlmapper/GoodsCmnSql.xml" />

    </mappers>

 

</configuration>



2. Acquiring a SqlSession from SqlSessionFactory

We should define a Class, SqlMapClient to acquire a sql session from SqlSessionFactory like the following.


==== SqlMapClient.java ====

package com.mobile.mybatis;


import java.io.IOException;

import java.io.Reader;


import org.apache.ibatis.io.Resources;

import org.apache.ibatis.session.SqlSession;

import org.apache.ibatis.session.SqlSessionFactory;

import org.apache.ibatis.session.SqlSessionFactoryBuilder;


public class SqlMapClient {

private static SqlSession session;

    

    public static SqlSession getSqlSession() {

    try {

             String resource = "mybatis.xml";

             Reader reader = Resources.getResourceAsReader(resource);

             SqlSessionFactory sqlMapper = new SqlSessionFactoryBuilder().build(reader);

              

             session = sqlMapper.openSession();

              

         } catch (IOException e) {

             e.printStackTrace();

         }

     

        return session;

    }

}



3. Mapping sql statements.

==== sampleSql.xml ====

<?xml version="1.0" encoding="UTF-8" ?>

 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">


 <mapper namespace="Test">

 

     <select id="getTeam" resultType="hashmap">

             SELECT

  

BD_CD AS CODE,

    BD_NM AS NAME

    FROM

 ESTB102

    WHERE

 CAMP_FG = '1'

          ORDER BY BD_NM

     </select>

 </mapper>

: Actually, it's very simple. We just define an id attribute and resultType.



4. Calling the method against the Mapper interface

==== SampleController.java ====

package com.mobile.test.process;


import java.util.List;

import java.util.Map;


import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


import org.apache.ibatis.session.SqlSession;


import com.mobile.log.Log;

import com.mobile.log.LogFactory;

import com.mobile.orm.GlobalSqlClientAssists;

import com.mobile.orm.SqlClientAssists;

import com.mobile.web.DataView;

import com.mobile.web.servlet.util.RequestData;

import com.mobile.mybatis.SqlMapClient;


public class MyBatisTestProcessor {

Log logger = LogFactory.getLog(MyBatisTestProcessor.class);

SqlSession session;

public MyBatisTestProcessor()

{

session = SqlMapClient.getSqlSession();

}

public DataView teamList(HttpServletRequest request, HttpServletResponse response,

DataView dataView, SqlClientAssists sqlClientAssists, GlobalSqlClientAssists globalSqlClientAssists,

RequestData reqData) throws Exception 

{

try{

       List<Map> list = session.selectList("Test.getTeam");

         

       for(Map map : list)

       {

        logger.info("###### " + map.get("CODE") + " ######");

        logger.info("###### " + map.get("NAME") + " ######");

       }

}finally{

session.close();

}

return dataView;

}

}


: "Test" means the namespace and "getTeam" means an id for the mapped statement, defining in the above sampleSql.xml.

We should specify the fully qualified name of "Test.getTeam".




+ Recent posts

출처: http://large.tistory.com/23 [Large]