我按照开发可滑动选项卡的教程进行操作.当我导入时:
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
Run Code Online (Sandbox Code Playgroud)
Android Studio显示我无法解析符号"ViewPager"和"FragmentActivity".怎么解决这个?谢谢.
以下是我项目的完整代码.
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
public class MainActivity extends FragmentActivity implements
ActionBar.TabListener {
private ViewPager viewPager;
private TabsPagerAdapter mAdapter;
private ActionBar actionBar;
// Tab titles
private String[] tabs = { "Top Rated", "Games", "Movies" };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initilization
viewPager = (ViewPager) findViewById(R.id.pager);
actionBar = getActionBar();
mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(mAdapter);
actionBar.setHomeButtonEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Adding Tabs
for (String tab_name …Run Code Online (Sandbox Code Playgroud) 当用户单击显示的文本时,此程序将弹出警告消息,然后将文本设置为大写.
<script src="jquery-min.js"></script>
<script>
//run once the page is loaded
jquery(document).ready(function ($) {
//Attach a click event to the span element
$('#test_span').click(function () {
//Read the elemnt's current value
var elemnt_text = $('#test_span').html();
//display the curretn value of this span
alert(element_text);
//convert the value to upper case
element_text = element_text.toUpperCase();
//change the span to this new value
$('#test_span').html(element_text);
});
});
</script>
</head>
<span id='test_span'>Testing jQuery</span>
Run Code Online (Sandbox Code Playgroud)