我的Widget启动服务,服务更新3个LinearLayouts列表.
我想在每个LinearLayout上设置一个具有不同Extra的SetOnClickPeningIntent
但是,当我启动小部件并想要点击LinearLayouts时,只有最后一个是onclickable = /我不知道什么是错的.希望您能够帮助我.
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.widget_layout);
for (int widgetId : appWidgetIds) {
int[] lls = { R.id.ll_con_1, R.id.ll_con_2, R.id.ll_con_3 };
for (int i = 0; i < jray.length(); i++) {
try {
JSONObject o = jray.getJSONObject(i);
//Onclick
if(i == 0)
{
Intent msg_intent = new Intent(getApplicationContext(), MSGsOpenMsg.class);
msg_intent.putExtra("messageid", o.getString("id"));
PendingIntent msg_pendingIntent = PendingIntent.getActivity(
getApplicationContext(), 0, msg_intent, Intent.FLAG_ACTIVITY_NEW_TASK);
remoteViews.setOnClickPendingIntent(R.id.ll_con_1, msg_pendingIntent);
}
else if(i == 1)
{
Intent msg_intent1 = new Intent(getApplicationContext(), MSGsOpenMsg.class);
msg_intent1.putExtra("messageid", o.getString("id"));
PendingIntent msg1_pendingIntent …Run Code Online (Sandbox Code Playgroud) 我有一个选项卡布局,活动显示在frameLayout中.如何通过再次单击"Home"-Tab从"主页"选项卡重新加载当前活动?
public class TabTestActivity extends TabActivity implements OnClickListener{
TabHost tabHost;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//MENÜ////////////////////////////////////////////
/** TabHost will have Tabs */
tabHost = (TabHost)findViewById(android.R.id.tabhost);
/** tid1 is firstTabSpec Id. Its used to access outside. */
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
TabSpec secondTabSpec = tabHost.newTabSpec("tid2");
TabSpec thirdTabSpec = tabHost.newTabSpec("tid3");
TabSpec fourthTabSpec = tabHost.newTabSpec("tid4");
/** TabSpec setIndicator() is used to set name for the tab. */
/** TabSpec setContent() …Run Code Online (Sandbox Code Playgroud)